-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmft.h
More file actions
107 lines (94 loc) · 3.49 KB
/
mft.h
File metadata and controls
107 lines (94 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Defines for mft record handling in NTFS Linux kernel driver.
*
* Copyright (c) 2001-2004 Anton Altaparmakov
*/
#ifndef _LINUX_NTFS_MFT_H
#define _LINUX_NTFS_MFT_H
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include "inode.h"
struct mft_record *map_mft_record(struct ntfs_inode *ni);
void unmap_mft_record(struct ntfs_inode *ni);
struct mft_record *map_extent_mft_record(struct ntfs_inode *base_ni, u64 mref,
struct ntfs_inode **ntfs_ino);
static inline void unmap_extent_mft_record(struct ntfs_inode *ni)
{
unmap_mft_record(ni);
}
void __mark_mft_record_dirty(struct ntfs_inode *ni);
/*
* mark_mft_record_dirty - set the mft record and the page containing it dirty
* @ni: ntfs inode describing the mapped mft record
*
* Set the mapped (extent) mft record of the (base or extent) ntfs inode @ni,
* as well as the page containing the mft record, dirty. Also, mark the base
* vfs inode dirty. This ensures that any changes to the mft record are
* written out to disk.
*
* NOTE: Do not do anything if the mft record is already marked dirty.
*/
static inline void mark_mft_record_dirty(struct ntfs_inode *ni)
{
if (!NInoTestSetDirty(ni))
__mark_mft_record_dirty(ni);
}
int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const unsigned long mft_no,
struct mft_record *m);
int write_mft_record_nolock(struct ntfs_inode *ni, struct mft_record *m, int sync);
/*
* write_mft_record - write out a mapped (extent) mft record
* @ni: ntfs inode describing the mapped (extent) mft record
* @m: mapped (extent) mft record to write
* @sync: if true, wait for i/o completion
*
* This is just a wrapper for write_mft_record_nolock() (see mft.c), which
* locks the page for the duration of the write. This ensures that there are
* no race conditions between writing the mft record via the dirty inode code
* paths and via the page cache write back code paths or between writing
* neighbouring mft records residing in the same page.
*
* Locking the page also serializes us against ->read_folio() if the page is not
* uptodate.
*
* On success, clean the mft record and return 0. On error, leave the mft
* record dirty and return -errno.
*/
static inline int write_mft_record(struct ntfs_inode *ni, struct mft_record *m, int sync)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
struct folio *folio = ni->folio;
int err;
folio_lock(folio);
err = write_mft_record_nolock(ni, m, sync);
folio_unlock(folio);
#else
struct page *page = ni->page;
int err;
BUG_ON(!page);
lock_page(page);
err = write_mft_record_nolock(ni, m, sync);
unlock_page(page);
#endif
return err;
}
bool ntfs_may_write_mft_record(struct ntfs_volume *vol,
const unsigned long mft_no, const struct mft_record *m,
struct ntfs_inode **locked_ni, struct inode **ref_vi);
int ntfs_mft_record_alloc(struct ntfs_volume *vol, const int mode,
struct ntfs_inode **ni, struct ntfs_inode *base_ni,
struct mft_record **ni_mrec);
int ntfs_mft_record_free(struct ntfs_volume *vol, struct ntfs_inode *ni);
int ntfs_mft_records_write(const struct ntfs_volume *vol, const u64 mref,
const s64 count, struct mft_record *b);
int ntfs_mft_record_check(const struct ntfs_volume *vol, struct mft_record *m,
unsigned long mft_no);
int ntfs_mft_writepages(struct address_space *mapping,
struct writeback_control *wbc);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
void ntfs_mft_mark_dirty(struct folio *folio);
#else
void ntfs_mft_mark_dirty(struct page *page);
#endif
#endif /* _LINUX_NTFS_MFT_H */