From 0c6ad673d45d6c4e49a226ffea05d86cbecdcea1 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 7 Oct 2004 13:10:19 +0100 Subject: [PATCH] NTFS: - Move ntfs_{un,}map_page() from ntfs.h to aops.h and fix resulting include errors. - Move typedefs for runlist_element and runlist from ntfs.h to runlist.h and fix resulting include errors. Signed-off-by: Anton Altaparmakov --- fs/ntfs/ChangeLog | 4 +++ fs/ntfs/aops.c | 4 +++ fs/ntfs/aops.h | 69 ++++++++++++++++++++++++++++++++++++++++- fs/ntfs/attrib.c | 4 +++ fs/ntfs/bitmap.c | 1 + fs/ntfs/collate.c | 3 +- fs/ntfs/compress.c | 2 ++ fs/ntfs/dir.c | 8 ++++- fs/ntfs/dir.h | 2 ++ fs/ntfs/file.c | 4 +++ fs/ntfs/index.c | 4 ++- fs/ntfs/inode.c | 3 ++ fs/ntfs/inode.h | 7 +++++ fs/ntfs/lcnalloc.c | 1 + fs/ntfs/lcnalloc.h | 1 + fs/ntfs/logfile.c | 4 ++- fs/ntfs/malloc.h | 1 + fs/ntfs/mft.c | 8 ++++- fs/ntfs/mft.h | 2 ++ fs/ntfs/namei.c | 4 ++- fs/ntfs/ntfs.h | 77 ++-------------------------------------------- fs/ntfs/quota.c | 3 +- fs/ntfs/runlist.c | 4 ++- fs/ntfs/runlist.h | 28 +++++++++++++++++ fs/ntfs/super.c | 5 ++- fs/ntfs/types.h | 28 ----------------- fs/ntfs/unistr.c | 2 ++ fs/ntfs/upcase.c | 1 + fs/ntfs/volume.h | 2 ++ 29 files changed, 173 insertions(+), 113 deletions(-) diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 78208d9bc6735..7b311ebd5318b 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -54,6 +54,10 @@ ToDo/Notes: - Switch fs/ntfs/index.h::ntfs_index_entry_mark_dirty() to using the new helper fs/ntfs/aops.c::mark_ntfs_record_dirty() and remove the no longer needed fs/ntfs/index.[hc]::__ntfs_index_entry_mark_dirty(). + - Move ntfs_{un,}map_page() from ntfs.h to aops.h and fix resulting + include errors. + - Move the typedefs for runlist_element and runlist from types.h to + runlist.h and fix resulting include errors. 2.1.20 - Fix two stupid bugs introduced in 2.1.18 release. diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index f09a3157c0c4a..61da8d51fd6ed 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -28,6 +28,10 @@ #include #include "aops.h" +#include "debug.h" +#include "inode.h" +#include "mft.h" +#include "types.h" #include "ntfs.h" /** diff --git a/fs/ntfs/aops.h b/fs/ntfs/aops.h index d1abd9e06467c..2bdadc1d533b4 100644 --- a/fs/ntfs/aops.h +++ b/fs/ntfs/aops.h @@ -24,10 +24,77 @@ #ifndef _LINUX_NTFS_AOPS_H #define _LINUX_NTFS_AOPS_H -#ifdef NTFS_RW +#include +#include +#include +#include #include "inode.h" +/** + * ntfs_unmap_page - release a page that was mapped using ntfs_map_page() + * @page: the page to release + * + * Unpin, unmap and release a page that was obtained from ntfs_map_page(). + */ +static inline void ntfs_unmap_page(struct page *page) +{ + kunmap(page); + page_cache_release(page); +} + +/** + * ntfs_map_page - map a page into accessible memory, reading it if necessary + * @mapping: address space for which to obtain the page + * @index: index into the page cache for @mapping of the page to map + * + * Read a page from the page cache of the address space @mapping at position + * @index, where @index is in units of PAGE_CACHE_SIZE, and not in bytes. + * + * If the page is not in memory it is loaded from disk first using the readpage + * method defined in the address space operations of @mapping and the page is + * added to the page cache of @mapping in the process. + * + * If the page is in high memory it is mapped into memory directly addressible + * by the kernel. + * + * Finally the page count is incremented, thus pinning the page into place. + * + * The above means that page_address(page) can be used on all pages obtained + * with ntfs_map_page() to get the kernel virtual address of the page. + * + * When finished with the page, the caller has to call ntfs_unmap_page() to + * unpin, unmap and release the page. + * + * Note this does not grant exclusive access. If such is desired, the caller + * must provide it independently of the ntfs_{un}map_page() calls by using + * a {rw_}semaphore or other means of serialization. A spin lock cannot be + * used as ntfs_map_page() can block. + * + * The unlocked and uptodate page is returned on success or an encoded error + * on failure. Caller has to test for error using the IS_ERR() macro on the + * return value. If that evaluates to TRUE, the negative error code can be + * obtained using PTR_ERR() on the return value of ntfs_map_page(). + */ +static inline struct page *ntfs_map_page(struct address_space *mapping, + unsigned long index) +{ + struct page *page = read_cache_page(mapping, index, + (filler_t*)mapping->a_ops->readpage, NULL); + + if (!IS_ERR(page)) { + wait_on_page_locked(page); + kmap(page); + if (PageUptodate(page) && !PageError(page)) + return page; + ntfs_unmap_page(page); + return ERR_PTR(-EIO); + } + return page; +} + +#ifdef NTFS_RW + extern void mark_ntfs_record_dirty(ntfs_inode *ni, struct page *page, unsigned int rec_start); diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index b8db01aaf3936..865de0c2c3d01 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -21,6 +21,10 @@ */ #include + +#include "attrib.h" +#include "debug.h" +#include "mft.h" #include "ntfs.h" /** diff --git a/fs/ntfs/bitmap.c b/fs/ntfs/bitmap.c index b8f06111f6ef5..12cf2e30c7dda 100644 --- a/fs/ntfs/bitmap.c +++ b/fs/ntfs/bitmap.c @@ -25,6 +25,7 @@ #include "bitmap.h" #include "debug.h" +#include "aops.h" #include "ntfs.h" /** diff --git a/fs/ntfs/collate.c b/fs/ntfs/collate.c index 31dd894a4319f..4a28ab3898ef3 100644 --- a/fs/ntfs/collate.c +++ b/fs/ntfs/collate.c @@ -19,8 +19,9 @@ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ntfs.h" #include "collate.h" +#include "debug.h" +#include "ntfs.h" static int ntfs_collate_binary(ntfs_volume *vol, const void *data1, const int data1_len, diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c index b4554e4bbbecc..b96fe5ff68dd1 100644 --- a/fs/ntfs/compress.c +++ b/fs/ntfs/compress.c @@ -25,6 +25,8 @@ #include #include +#include "inode.h" +#include "debug.h" #include "ntfs.h" /** diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c index ed9838e0c5d08..2700e4bd55743 100644 --- a/fs/ntfs/dir.c +++ b/fs/ntfs/dir.c @@ -21,8 +21,14 @@ */ #include -#include "ntfs.h" +#include + #include "dir.h" +#include "aops.h" +#include "attrib.h" +#include "mft.h" +#include "debug.h" +#include "ntfs.h" /** * The little endian Unicode string $I30 as a global constant. diff --git a/fs/ntfs/dir.h b/fs/ntfs/dir.h index 90a8c3f652031..aea7582d561fc 100644 --- a/fs/ntfs/dir.h +++ b/fs/ntfs/dir.h @@ -24,6 +24,8 @@ #define _LINUX_NTFS_DIR_H #include "layout.h" +#include "inode.h" +#include "types.h" /* * ntfs_name is used to return the file name to the caller of diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index c7880d55b250d..e808649d5a8fe 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -19,6 +19,10 @@ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include + +#include "debug.h" #include "ntfs.h" /** diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c index 11be36f68bc99..aded65d13a655 100644 --- a/fs/ntfs/index.c +++ b/fs/ntfs/index.c @@ -19,9 +19,11 @@ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ntfs.h" +#include "aops.h" #include "collate.h" +#include "debug.h" #include "index.h" +#include "ntfs.h" /** * ntfs_index_ctx_get - allocate and initialize a new index context diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 8c48de078c411..a592f57b5dbb4 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -27,8 +27,11 @@ #include "ntfs.h" #include "dir.h" +#include "debug.h" #include "inode.h" #include "attrib.h" +#include "malloc.h" +#include "mft.h" #include "time.h" /** diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h index 3aa7b873fe0df..bf1d906d16913 100644 --- a/fs/ntfs/inode.h +++ b/fs/ntfs/inode.h @@ -24,10 +24,17 @@ #ifndef _LINUX_NTFS_INODE_H #define _LINUX_NTFS_INODE_H +#include +#include #include +#include +#include +#include #include "layout.h" #include "volume.h" +#include "types.h" +#include "runlist.h" typedef struct _ntfs_inode ntfs_inode; diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c index 5f291021a193f..17888c9f02f16 100644 --- a/fs/ntfs/lcnalloc.c +++ b/fs/ntfs/lcnalloc.c @@ -30,6 +30,7 @@ #include "volume.h" #include "attrib.h" #include "malloc.h" +#include "aops.h" #include "ntfs.h" /** diff --git a/fs/ntfs/lcnalloc.h b/fs/ntfs/lcnalloc.h index b9ebb31100a1e..4cac1c024af60 100644 --- a/fs/ntfs/lcnalloc.h +++ b/fs/ntfs/lcnalloc.h @@ -28,6 +28,7 @@ #include #include "types.h" +#include "runlist.h" #include "volume.h" typedef enum { diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c index 84ed2ef14a325..9f20835e04a95 100644 --- a/fs/ntfs/logfile.c +++ b/fs/ntfs/logfile.c @@ -29,8 +29,10 @@ #include "logfile.h" #include "volume.h" -#include "ntfs.h" +#include "aops.h" #include "debug.h" +#include "malloc.h" +#include "ntfs.h" /** * ntfs_check_restart_page_header - check the page header for consistency diff --git a/fs/ntfs/malloc.h b/fs/ntfs/malloc.h index c8548a5336e00..fac5944df6d80 100644 --- a/fs/ntfs/malloc.h +++ b/fs/ntfs/malloc.h @@ -24,6 +24,7 @@ #include #include +#include /** * ntfs_malloc_nofs - allocate memory in multiples of pages diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 4b9be65ca33d0..99aa4decb9c2e 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -20,10 +20,16 @@ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include -#include "ntfs.h" #include "bitmap.h" +#include "lcnalloc.h" +#include "aops.h" +#include "debug.h" +#include "mft.h" +#include "malloc.h" +#include "ntfs.h" /** * __format_mft_record - initialize an empty mft record diff --git a/fs/ntfs/mft.h b/fs/ntfs/mft.h index 5f3566779fa8e..924f87abff8b9 100644 --- a/fs/ntfs/mft.h +++ b/fs/ntfs/mft.h @@ -24,6 +24,8 @@ #define _LINUX_NTFS_MFT_H #include +#include +#include #include "inode.h" diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c index 70b503a85f4d1..b47084f0607bb 100644 --- a/fs/ntfs/namei.c +++ b/fs/ntfs/namei.c @@ -23,8 +23,10 @@ #include #include -#include "ntfs.h" #include "dir.h" +#include "debug.h" +#include "mft.h" +#include "ntfs.h" /** * ntfs_lookup - find the inode represented by a dentry in a directory inode diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h index c3fda17158e6e..d65c401ccbc3d 100644 --- a/fs/ntfs/ntfs.h +++ b/fs/ntfs/ntfs.h @@ -29,21 +29,12 @@ #include #include #include -#include #include -#include #include -#include #include "types.h" -#include "debug.h" -#include "malloc.h" -#include "endian.h" #include "volume.h" -#include "inode.h" #include "layout.h" -#include "attrib.h" -#include "mft.h" typedef enum { NTFS_BLOCK_SIZE = 512, @@ -87,72 +78,12 @@ static inline ntfs_volume *NTFS_SB(struct super_block *sb) return sb->s_fs_info; } -/** - * ntfs_unmap_page - release a page that was mapped using ntfs_map_page() - * @page: the page to release - * - * Unpin, unmap and release a page that was obtained from ntfs_map_page(). - */ -static inline void ntfs_unmap_page(struct page *page) -{ - kunmap(page); - page_cache_release(page); -} - -/** - * ntfs_map_page - map a page into accessible memory, reading it if necessary - * @mapping: address space for which to obtain the page - * @index: index into the page cache for @mapping of the page to map - * - * Read a page from the page cache of the address space @mapping at position - * @index, where @index is in units of PAGE_CACHE_SIZE, and not in bytes. - * - * If the page is not in memory it is loaded from disk first using the readpage - * method defined in the address space operations of @mapping and the page is - * added to the page cache of @mapping in the process. - * - * If the page is in high memory it is mapped into memory directly addressible - * by the kernel. - * - * Finally the page count is incremented, thus pinning the page into place. - * - * The above means that page_address(page) can be used on all pages obtained - * with ntfs_map_page() to get the kernel virtual address of the page. - * - * When finished with the page, the caller has to call ntfs_unmap_page() to - * unpin, unmap and release the page. - * - * Note this does not grant exclusive access. If such is desired, the caller - * must provide it independently of the ntfs_{un}map_page() calls by using - * a {rw_}semaphore or other means of serialization. A spin lock cannot be - * used as ntfs_map_page() can block. - * - * The unlocked and uptodate page is returned on success or an encoded error - * on failure. Caller has to test for error using the IS_ERR() macro on the - * return value. If that evaluates to TRUE, the negative error code can be - * obtained using PTR_ERR() on the return value of ntfs_map_page(). - */ -static inline struct page *ntfs_map_page(struct address_space *mapping, - unsigned long index) -{ - struct page *page = read_cache_page(mapping, index, - (filler_t*)mapping->a_ops->readpage, NULL); - - if (!IS_ERR(page)) { - wait_on_page_locked(page); - kmap(page); - if (PageUptodate(page) && !PageError(page)) - return page; - ntfs_unmap_page(page); - return ERR_PTR(-EIO); - } - return page; -} - /* Declarations of functions and global variables. */ /* From fs/ntfs/compress.c */ extern int ntfs_read_compressed_block(struct page *page); +extern int allocate_compression_buffers(void); +extern void free_compression_buffers(void); /* From fs/ntfs/super.c */ #define default_upcase_len 0x10000 @@ -166,10 +97,6 @@ typedef struct { } option_t; extern const option_t on_errors_arr[]; -/* From fs/ntfs/compress.c */ -extern int allocate_compression_buffers(void); -extern void free_compression_buffers(void); - /* From fs/ntfs/mst.c */ extern int post_read_mst_fixup(NTFS_RECORD *b, const u32 size); extern int pre_write_mst_fixup(NTFS_RECORD *b, const u32 size); diff --git a/fs/ntfs/quota.c b/fs/ntfs/quota.c index b72a85dd446f9..8764ebd8d063b 100644 --- a/fs/ntfs/quota.c +++ b/fs/ntfs/quota.c @@ -22,9 +22,10 @@ #ifdef NTFS_RW -#include "ntfs.h" #include "index.h" #include "quota.h" +#include "debug.h" +#include "ntfs.h" /** * ntfs_mark_quotas_out_of_date - mark the quotas out of date on an ntfs volume diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c index b900f2fde18d3..6b9ca6883581c 100644 --- a/fs/ntfs/runlist.c +++ b/fs/ntfs/runlist.c @@ -20,8 +20,10 @@ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ntfs.h" #include "dir.h" +#include "debug.h" +#include "malloc.h" +#include "ntfs.h" /** * ntfs_rl_mm - runlist memmove diff --git a/fs/ntfs/runlist.h b/fs/ntfs/runlist.h index 7d82f4bd87d39..7107fde59df9c 100644 --- a/fs/ntfs/runlist.h +++ b/fs/ntfs/runlist.h @@ -28,6 +28,34 @@ #include "layout.h" #include "volume.h" +/** + * runlist_element - in memory vcn to lcn mapping array element + * @vcn: starting vcn of the current array element + * @lcn: starting lcn of the current array element + * @length: length in clusters of the current array element + * + * The last vcn (in fact the last vcn + 1) is reached when length == 0. + * + * When lcn == -1 this means that the count vcns starting at vcn are not + * physically allocated (i.e. this is a hole / data is sparse). + */ +typedef struct { /* In memory vcn to lcn mapping structure element. */ + VCN vcn; /* vcn = Starting virtual cluster number. */ + LCN lcn; /* lcn = Starting logical cluster number. */ + s64 length; /* Run length in clusters. */ +} runlist_element; + +/** + * runlist - in memory vcn to lcn mapping array including a read/write lock + * @rl: pointer to an array of runlist elements + * @lock: read/write spinlock for serializing access to @rl + * + */ +typedef struct { + runlist_element *rl; + struct rw_semaphore lock; +} runlist; + static inline void ntfs_init_runlist(runlist *rl) { rl->rl = NULL; diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 7d2a7b668f817..7edbdefd9d7a2 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -31,12 +31,15 @@ #include #include -#include "ntfs.h" #include "sysctl.h" #include "logfile.h" #include "quota.h" #include "dir.h" +#include "debug.h" #include "index.h" +#include "aops.h" +#include "malloc.h" +#include "ntfs.h" /* Number of mounted file systems which have compression enabled. */ static unsigned long ntfs_nr_compression_users; diff --git a/fs/ntfs/types.h b/fs/ntfs/types.h index a98731ece42e4..08a55aa53d4e5 100644 --- a/fs/ntfs/types.h +++ b/fs/ntfs/types.h @@ -53,34 +53,6 @@ typedef sle64 leLCN; typedef s64 LSN; typedef sle64 leLSN; -/** - * runlist_element - in memory vcn to lcn mapping array element - * @vcn: starting vcn of the current array element - * @lcn: starting lcn of the current array element - * @length: length in clusters of the current array element - * - * The last vcn (in fact the last vcn + 1) is reached when length == 0. - * - * When lcn == -1 this means that the count vcns starting at vcn are not - * physically allocated (i.e. this is a hole / data is sparse). - */ -typedef struct { /* In memory vcn to lcn mapping structure element. */ - VCN vcn; /* vcn = Starting virtual cluster number. */ - LCN lcn; /* lcn = Starting logical cluster number. */ - s64 length; /* Run length in clusters. */ -} runlist_element; - -/** - * runlist - in memory vcn to lcn mapping array including a read/write lock - * @rl: pointer to an array of runlist elements - * @lock: read/write spinlock for serializing access to @rl - * - */ -typedef struct { - runlist_element *rl; - struct rw_semaphore lock; -} runlist; - typedef enum { FALSE = 0, TRUE = 1 diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c index ec7405a80b4cb..560b0ea255b0b 100644 --- a/fs/ntfs/unistr.c +++ b/fs/ntfs/unistr.c @@ -19,6 +19,8 @@ * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "types.h" +#include "debug.h" #include "ntfs.h" /* diff --git a/fs/ntfs/upcase.c b/fs/ntfs/upcase.c index 276ed97982d32..879cdf1d5bd39 100644 --- a/fs/ntfs/upcase.c +++ b/fs/ntfs/upcase.c @@ -24,6 +24,7 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "malloc.h" #include "ntfs.h" ntfschar *generate_default_upcase(void) diff --git a/fs/ntfs/volume.h b/fs/ntfs/volume.h index 4d0541350fff8..4b97fa8635a89 100644 --- a/fs/ntfs/volume.h +++ b/fs/ntfs/volume.h @@ -24,6 +24,8 @@ #ifndef _LINUX_NTFS_VOLUME_H #define _LINUX_NTFS_VOLUME_H +#include + #include "types.h" #include "layout.h" -- 2.53.0