Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * mft.h - Defines for mft record handling in NTFS Linux kernel driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *	   Part of the Linux-NTFS project.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (c) 2001-2004 Anton Altaparmakov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef _LINUX_NTFS_MFT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define _LINUX_NTFS_MFT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/highmem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "inode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) extern MFT_RECORD *map_mft_record(ntfs_inode *ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) extern void unmap_mft_record(ntfs_inode *ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) extern MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		ntfs_inode **ntfs_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static inline void unmap_extent_mft_record(ntfs_inode *ni)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	unmap_mft_record(ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #ifdef NTFS_RW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * flush_dcache_mft_record_page - flush_dcache_page() for mft records
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * @ni:		ntfs inode structure of mft record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * Call flush_dcache_page() for the page in which an mft record resides.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * This must be called every time an mft record is modified, just after the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * modification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) static inline void flush_dcache_mft_record_page(ntfs_inode *ni)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	flush_dcache_page(ni->page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) extern void __mark_mft_record_dirty(ntfs_inode *ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * mark_mft_record_dirty - set the mft record and the page containing it dirty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * @ni:		ntfs inode describing the mapped mft record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * Set the mapped (extent) mft record of the (base or extent) ntfs inode @ni,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * as well as the page containing the mft record, dirty.  Also, mark the base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * vfs inode dirty.  This ensures that any changes to the mft record are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * written out to disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * NOTE:  Do not do anything if the mft record is already marked dirty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static inline void mark_mft_record_dirty(ntfs_inode *ni)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	if (!NInoTestSetDirty(ni))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		__mark_mft_record_dirty(ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) extern int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		MFT_RECORD *m, int sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) extern int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * write_mft_record - write out a mapped (extent) mft record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @ni:		ntfs inode describing the mapped (extent) mft record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @m:		mapped (extent) mft record to write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * @sync:	if true, wait for i/o completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * This is just a wrapper for write_mft_record_nolock() (see mft.c), which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * locks the page for the duration of the write.  This ensures that there are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * no race conditions between writing the mft record via the dirty inode code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * paths and via the page cache write back code paths or between writing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * neighbouring mft records residing in the same page.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * Locking the page also serializes us against ->readpage() if the page is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * uptodate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * On success, clean the mft record and return 0.  On error, leave the mft
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * record dirty and return -errno.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static inline int write_mft_record(ntfs_inode *ni, MFT_RECORD *m, int sync)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	struct page *page = ni->page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	BUG_ON(!page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	lock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	err = write_mft_record_nolock(ni, m, sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	unlock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) extern bool ntfs_may_write_mft_record(ntfs_volume *vol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		const unsigned long mft_no, const MFT_RECORD *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		ntfs_inode **locked_ni);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) extern ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		ntfs_inode *base_ni, MFT_RECORD **mrec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) extern int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #endif /* NTFS_RW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #endif /* _LINUX_NTFS_MFT_H */