diff options
author | Joel Becker <joel.becker@oracle.com> | 2009-02-10 23:00:41 -0500 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-04 19:07:48 -0400 |
commit | 8cb471e8f82506937fe5e2e9fb0bf90f6b1f1170 (patch) | |
tree | e275a8f5db101a9990ba44931cfd116123112b11 /fs | |
parent | 6e5a3d7538ad4e46a976862f593faf65750e37cc (diff) |
ocfs2: Take the inode out of the metadata read/write paths.
We are really passing the inode into the ocfs2_read/write_blocks()
functions to get at the metadata cache. This commit passes the cache
directly into the metadata block functions, divorcing them from the
inode.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/alloc.c | 13 | ||||
-rw-r--r-- | fs/ocfs2/buffer_head_io.c | 47 | ||||
-rw-r--r-- | fs/ocfs2/buffer_head_io.h | 8 | ||||
-rw-r--r-- | fs/ocfs2/dir.c | 23 | ||||
-rw-r--r-- | fs/ocfs2/dlmglue.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/extent_map.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/inode.c | 24 | ||||
-rw-r--r-- | fs/ocfs2/inode.h | 5 | ||||
-rw-r--r-- | fs/ocfs2/journal.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/localalloc.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 5 | ||||
-rw-r--r-- | fs/ocfs2/quota_global.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/quota_local.c | 6 | ||||
-rw-r--r-- | fs/ocfs2/resize.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/slot_map.c | 10 | ||||
-rw-r--r-- | fs/ocfs2/suballoc.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/uptodate.c | 83 | ||||
-rw-r--r-- | fs/ocfs2/uptodate.h | 21 | ||||
-rw-r--r-- | fs/ocfs2/xattr.c | 23 |
20 files changed, 156 insertions, 134 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index ab513ddaeff2..d5dffcfa192a 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -859,7 +859,7 @@ int ocfs2_read_extent_block(struct inode *inode, u64 eb_blkno, | |||
859 | int rc; | 859 | int rc; |
860 | struct buffer_head *tmp = *bh; | 860 | struct buffer_head *tmp = *bh; |
861 | 861 | ||
862 | rc = ocfs2_read_block(inode, eb_blkno, &tmp, | 862 | rc = ocfs2_read_block(INODE_CACHE(inode), eb_blkno, &tmp, |
863 | ocfs2_validate_extent_block); | 863 | ocfs2_validate_extent_block); |
864 | 864 | ||
865 | /* If ocfs2_read_block() got us a new bh, pass it up. */ | 865 | /* If ocfs2_read_block() got us a new bh, pass it up. */ |
@@ -949,7 +949,8 @@ static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, | |||
949 | mlog_errno(status); | 949 | mlog_errno(status); |
950 | goto bail; | 950 | goto bail; |
951 | } | 951 | } |
952 | ocfs2_set_new_buffer_uptodate(inode, bhs[i]); | 952 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), |
953 | bhs[i]); | ||
953 | 954 | ||
954 | status = ocfs2_journal_access_eb(handle, inode, bhs[i], | 955 | status = ocfs2_journal_access_eb(handle, inode, bhs[i], |
955 | OCFS2_JOURNAL_ACCESS_CREATE); | 956 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -2559,7 +2560,7 @@ static void ocfs2_unlink_path(struct inode *inode, handle_t *handle, | |||
2559 | le16_to_cpu(el->l_next_free_rec)); | 2560 | le16_to_cpu(el->l_next_free_rec)); |
2560 | 2561 | ||
2561 | ocfs2_journal_dirty(handle, bh); | 2562 | ocfs2_journal_dirty(handle, bh); |
2562 | ocfs2_remove_from_cache(inode, bh); | 2563 | ocfs2_remove_from_cache(INODE_CACHE(inode), bh); |
2563 | continue; | 2564 | continue; |
2564 | } | 2565 | } |
2565 | 2566 | ||
@@ -2572,7 +2573,7 @@ static void ocfs2_unlink_path(struct inode *inode, handle_t *handle, | |||
2572 | if (ret) | 2573 | if (ret) |
2573 | mlog_errno(ret); | 2574 | mlog_errno(ret); |
2574 | 2575 | ||
2575 | ocfs2_remove_from_cache(inode, bh); | 2576 | ocfs2_remove_from_cache(INODE_CACHE(inode), bh); |
2576 | } | 2577 | } |
2577 | } | 2578 | } |
2578 | 2579 | ||
@@ -6010,7 +6011,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, | |||
6010 | tl->tl_used = 0; | 6011 | tl->tl_used = 0; |
6011 | 6012 | ||
6012 | ocfs2_compute_meta_ecc(osb->sb, tl_bh->b_data, &di->i_check); | 6013 | ocfs2_compute_meta_ecc(osb->sb, tl_bh->b_data, &di->i_check); |
6013 | status = ocfs2_write_block(osb, tl_bh, tl_inode); | 6014 | status = ocfs2_write_block(osb, tl_bh, INODE_CACHE(tl_inode)); |
6014 | if (status < 0) { | 6015 | if (status < 0) { |
6015 | mlog_errno(status); | 6016 | mlog_errno(status); |
6016 | goto bail; | 6017 | goto bail; |
@@ -6719,7 +6720,7 @@ delete: | |||
6719 | 6720 | ||
6720 | mlog(0, "deleting this extent block.\n"); | 6721 | mlog(0, "deleting this extent block.\n"); |
6721 | 6722 | ||
6722 | ocfs2_remove_from_cache(inode, bh); | 6723 | ocfs2_remove_from_cache(INODE_CACHE(inode), bh); |
6723 | 6724 | ||
6724 | BUG_ON(ocfs2_rec_clusters(el, &el->l_recs[0])); | 6725 | BUG_ON(ocfs2_rec_clusters(el, &el->l_recs[0])); |
6725 | BUG_ON(le32_to_cpu(el->l_recs[0].e_cpos)); | 6726 | BUG_ON(le32_to_cpu(el->l_recs[0].e_cpos)); |
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c index 15c8e6deee2e..d43d34a1dd31 100644 --- a/fs/ocfs2/buffer_head_io.c +++ b/fs/ocfs2/buffer_head_io.c | |||
@@ -52,12 +52,12 @@ enum ocfs2_state_bits { | |||
52 | BUFFER_FNS(NeedsValidate, needs_validate); | 52 | BUFFER_FNS(NeedsValidate, needs_validate); |
53 | 53 | ||
54 | int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | 54 | int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, |
55 | struct inode *inode) | 55 | struct ocfs2_caching_info *ci) |
56 | { | 56 | { |
57 | int ret = 0; | 57 | int ret = 0; |
58 | 58 | ||
59 | mlog_entry("(bh->b_blocknr = %llu, inode=%p)\n", | 59 | mlog_entry("(bh->b_blocknr = %llu, ci=%p)\n", |
60 | (unsigned long long)bh->b_blocknr, inode); | 60 | (unsigned long long)bh->b_blocknr, ci); |
61 | 61 | ||
62 | BUG_ON(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO); | 62 | BUG_ON(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO); |
63 | BUG_ON(buffer_jbd(bh)); | 63 | BUG_ON(buffer_jbd(bh)); |
@@ -70,7 +70,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | |||
70 | goto out; | 70 | goto out; |
71 | } | 71 | } |
72 | 72 | ||
73 | mutex_lock(&OCFS2_I(inode)->ip_io_mutex); | 73 | ocfs2_metadata_cache_io_lock(ci); |
74 | 74 | ||
75 | lock_buffer(bh); | 75 | lock_buffer(bh); |
76 | set_buffer_uptodate(bh); | 76 | set_buffer_uptodate(bh); |
@@ -85,7 +85,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | |||
85 | wait_on_buffer(bh); | 85 | wait_on_buffer(bh); |
86 | 86 | ||
87 | if (buffer_uptodate(bh)) { | 87 | if (buffer_uptodate(bh)) { |
88 | ocfs2_set_buffer_uptodate(inode, bh); | 88 | ocfs2_set_buffer_uptodate(ci, bh); |
89 | } else { | 89 | } else { |
90 | /* We don't need to remove the clustered uptodate | 90 | /* We don't need to remove the clustered uptodate |
91 | * information for this bh as it's not marked locally | 91 | * information for this bh as it's not marked locally |
@@ -94,7 +94,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | |||
94 | put_bh(bh); | 94 | put_bh(bh); |
95 | } | 95 | } |
96 | 96 | ||
97 | mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); | 97 | ocfs2_metadata_cache_io_unlock(ci); |
98 | out: | 98 | out: |
99 | mlog_exit(ret); | 99 | mlog_exit(ret); |
100 | return ret; | 100 | return ret; |
@@ -177,7 +177,7 @@ bail: | |||
177 | return status; | 177 | return status; |
178 | } | 178 | } |
179 | 179 | ||
180 | int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | 180 | int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, |
181 | struct buffer_head *bhs[], int flags, | 181 | struct buffer_head *bhs[], int flags, |
182 | int (*validate)(struct super_block *sb, | 182 | int (*validate)(struct super_block *sb, |
183 | struct buffer_head *bh)) | 183 | struct buffer_head *bh)) |
@@ -185,11 +185,12 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
185 | int status = 0; | 185 | int status = 0; |
186 | int i, ignore_cache = 0; | 186 | int i, ignore_cache = 0; |
187 | struct buffer_head *bh; | 187 | struct buffer_head *bh; |
188 | struct super_block *sb = ocfs2_metadata_cache_get_super(ci); | ||
188 | 189 | ||
189 | mlog_entry("(inode=%p, block=(%llu), nr=(%d), flags=%d)\n", | 190 | mlog_entry("(ci=%p, block=(%llu), nr=(%d), flags=%d)\n", |
190 | inode, (unsigned long long)block, nr, flags); | 191 | ci, (unsigned long long)block, nr, flags); |
191 | 192 | ||
192 | BUG_ON(!inode); | 193 | BUG_ON(!ci); |
193 | BUG_ON((flags & OCFS2_BH_READAHEAD) && | 194 | BUG_ON((flags & OCFS2_BH_READAHEAD) && |
194 | (flags & OCFS2_BH_IGNORE_CACHE)); | 195 | (flags & OCFS2_BH_IGNORE_CACHE)); |
195 | 196 | ||
@@ -212,12 +213,12 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
212 | goto bail; | 213 | goto bail; |
213 | } | 214 | } |
214 | 215 | ||
215 | mutex_lock(&OCFS2_I(inode)->ip_io_mutex); | 216 | ocfs2_metadata_cache_io_lock(ci); |
216 | for (i = 0 ; i < nr ; i++) { | 217 | for (i = 0 ; i < nr ; i++) { |
217 | if (bhs[i] == NULL) { | 218 | if (bhs[i] == NULL) { |
218 | bhs[i] = sb_getblk(inode->i_sb, block++); | 219 | bhs[i] = sb_getblk(sb, block++); |
219 | if (bhs[i] == NULL) { | 220 | if (bhs[i] == NULL) { |
220 | mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); | 221 | ocfs2_metadata_cache_io_unlock(ci); |
221 | status = -EIO; | 222 | status = -EIO; |
222 | mlog_errno(status); | 223 | mlog_errno(status); |
223 | goto bail; | 224 | goto bail; |
@@ -250,11 +251,11 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
250 | * before our is-it-in-flight check. | 251 | * before our is-it-in-flight check. |
251 | */ | 252 | */ |
252 | 253 | ||
253 | if (!ignore_cache && !ocfs2_buffer_uptodate(inode, bh)) { | 254 | if (!ignore_cache && !ocfs2_buffer_uptodate(ci, bh)) { |
254 | mlog(ML_UPTODATE, | 255 | mlog(ML_UPTODATE, |
255 | "bh (%llu), inode %llu not uptodate\n", | 256 | "bh (%llu), owner %llu not uptodate\n", |
256 | (unsigned long long)bh->b_blocknr, | 257 | (unsigned long long)bh->b_blocknr, |
257 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 258 | (unsigned long long)ocfs2_metadata_cache_owner(ci)); |
258 | /* We're using ignore_cache here to say | 259 | /* We're using ignore_cache here to say |
259 | * "go to disk" */ | 260 | * "go to disk" */ |
260 | ignore_cache = 1; | 261 | ignore_cache = 1; |
@@ -283,7 +284,7 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
283 | * previously submitted request than we are | 284 | * previously submitted request than we are |
284 | * done here. */ | 285 | * done here. */ |
285 | if ((flags & OCFS2_BH_READAHEAD) | 286 | if ((flags & OCFS2_BH_READAHEAD) |
286 | && ocfs2_buffer_read_ahead(inode, bh)) | 287 | && ocfs2_buffer_read_ahead(ci, bh)) |
287 | continue; | 288 | continue; |
288 | 289 | ||
289 | lock_buffer(bh); | 290 | lock_buffer(bh); |
@@ -305,7 +306,7 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
305 | * buffer lock. */ | 306 | * buffer lock. */ |
306 | if (!(flags & OCFS2_BH_IGNORE_CACHE) | 307 | if (!(flags & OCFS2_BH_IGNORE_CACHE) |
307 | && !(flags & OCFS2_BH_READAHEAD) | 308 | && !(flags & OCFS2_BH_READAHEAD) |
308 | && ocfs2_buffer_uptodate(inode, bh)) { | 309 | && ocfs2_buffer_uptodate(ci, bh)) { |
309 | unlock_buffer(bh); | 310 | unlock_buffer(bh); |
310 | continue; | 311 | continue; |
311 | } | 312 | } |
@@ -327,7 +328,7 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
327 | 328 | ||
328 | if (!(flags & OCFS2_BH_READAHEAD)) { | 329 | if (!(flags & OCFS2_BH_READAHEAD)) { |
329 | /* We know this can't have changed as we hold the | 330 | /* We know this can't have changed as we hold the |
330 | * inode sem. Avoid doing any work on the bh if the | 331 | * owner sem. Avoid doing any work on the bh if the |
331 | * journal has it. */ | 332 | * journal has it. */ |
332 | if (!buffer_jbd(bh)) | 333 | if (!buffer_jbd(bh)) |
333 | wait_on_buffer(bh); | 334 | wait_on_buffer(bh); |
@@ -351,7 +352,7 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
351 | * that better not have changed */ | 352 | * that better not have changed */ |
352 | BUG_ON(buffer_jbd(bh)); | 353 | BUG_ON(buffer_jbd(bh)); |
353 | clear_buffer_needs_validate(bh); | 354 | clear_buffer_needs_validate(bh); |
354 | status = validate(inode->i_sb, bh); | 355 | status = validate(sb, bh); |
355 | if (status) { | 356 | if (status) { |
356 | put_bh(bh); | 357 | put_bh(bh); |
357 | bhs[i] = NULL; | 358 | bhs[i] = NULL; |
@@ -363,9 +364,9 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
363 | /* Always set the buffer in the cache, even if it was | 364 | /* Always set the buffer in the cache, even if it was |
364 | * a forced read, or read-ahead which hasn't yet | 365 | * a forced read, or read-ahead which hasn't yet |
365 | * completed. */ | 366 | * completed. */ |
366 | ocfs2_set_buffer_uptodate(inode, bh); | 367 | ocfs2_set_buffer_uptodate(ci, bh); |
367 | } | 368 | } |
368 | mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); | 369 | ocfs2_metadata_cache_io_unlock(ci); |
369 | 370 | ||
370 | mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n", | 371 | mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n", |
371 | (unsigned long long)block, nr, | 372 | (unsigned long long)block, nr, |
@@ -399,7 +400,7 @@ static void ocfs2_check_super_or_backup(struct super_block *sb, | |||
399 | 400 | ||
400 | /* | 401 | /* |
401 | * Write super block and backups doesn't need to collaborate with journal, | 402 | * Write super block and backups doesn't need to collaborate with journal, |
402 | * so we don't need to lock ip_io_mutex and inode doesn't need to bea passed | 403 | * so we don't need to lock ip_io_mutex and ci doesn't need to bea passed |
403 | * into this function. | 404 | * into this function. |
404 | */ | 405 | */ |
405 | int ocfs2_write_super_or_backup(struct ocfs2_super *osb, | 406 | int ocfs2_write_super_or_backup(struct ocfs2_super *osb, |
diff --git a/fs/ocfs2/buffer_head_io.h b/fs/ocfs2/buffer_head_io.h index c75d682dadd8..b97bcc6dde7c 100644 --- a/fs/ocfs2/buffer_head_io.h +++ b/fs/ocfs2/buffer_head_io.h | |||
@@ -33,7 +33,7 @@ void ocfs2_end_buffer_io_sync(struct buffer_head *bh, | |||
33 | 33 | ||
34 | int ocfs2_write_block(struct ocfs2_super *osb, | 34 | int ocfs2_write_block(struct ocfs2_super *osb, |
35 | struct buffer_head *bh, | 35 | struct buffer_head *bh, |
36 | struct inode *inode); | 36 | struct ocfs2_caching_info *ci); |
37 | int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, | 37 | int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, |
38 | unsigned int nr, struct buffer_head *bhs[]); | 38 | unsigned int nr, struct buffer_head *bhs[]); |
39 | 39 | ||
@@ -44,7 +44,7 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, | |||
44 | * be set even for a READAHEAD call, as it marks the buffer for later | 44 | * be set even for a READAHEAD call, as it marks the buffer for later |
45 | * validation. | 45 | * validation. |
46 | */ | 46 | */ |
47 | int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | 47 | int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, |
48 | struct buffer_head *bhs[], int flags, | 48 | struct buffer_head *bhs[], int flags, |
49 | int (*validate)(struct super_block *sb, | 49 | int (*validate)(struct super_block *sb, |
50 | struct buffer_head *bh)); | 50 | struct buffer_head *bh)); |
@@ -55,7 +55,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, | |||
55 | #define OCFS2_BH_IGNORE_CACHE 1 | 55 | #define OCFS2_BH_IGNORE_CACHE 1 |
56 | #define OCFS2_BH_READAHEAD 8 | 56 | #define OCFS2_BH_READAHEAD 8 |
57 | 57 | ||
58 | static inline int ocfs2_read_block(struct inode *inode, u64 off, | 58 | static inline int ocfs2_read_block(struct ocfs2_caching_info *ci, u64 off, |
59 | struct buffer_head **bh, | 59 | struct buffer_head **bh, |
60 | int (*validate)(struct super_block *sb, | 60 | int (*validate)(struct super_block *sb, |
61 | struct buffer_head *bh)) | 61 | struct buffer_head *bh)) |
@@ -68,7 +68,7 @@ static inline int ocfs2_read_block(struct inode *inode, u64 off, | |||
68 | goto bail; | 68 | goto bail; |
69 | } | 69 | } |
70 | 70 | ||
71 | status = ocfs2_read_blocks(inode, off, 1, bh, 0, validate); | 71 | status = ocfs2_read_blocks(ci, off, 1, bh, 0, validate); |
72 | 72 | ||
73 | bail: | 73 | bail: |
74 | return status; | 74 | return status; |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index b358f3bf896d..273fb7648fce 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -564,7 +564,8 @@ static int ocfs2_read_dir_block_direct(struct inode *dir, u64 phys, | |||
564 | int ret; | 564 | int ret; |
565 | struct buffer_head *tmp = *bh; | 565 | struct buffer_head *tmp = *bh; |
566 | 566 | ||
567 | ret = ocfs2_read_block(dir, phys, &tmp, ocfs2_validate_dir_block); | 567 | ret = ocfs2_read_block(INODE_CACHE(dir), phys, &tmp, |
568 | ocfs2_validate_dir_block); | ||
568 | if (ret) { | 569 | if (ret) { |
569 | mlog_errno(ret); | 570 | mlog_errno(ret); |
570 | goto out; | 571 | goto out; |
@@ -622,7 +623,8 @@ static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di, | |||
622 | u64 blkno = le64_to_cpu(di->i_dx_root); | 623 | u64 blkno = le64_to_cpu(di->i_dx_root); |
623 | struct buffer_head *tmp = *dx_root_bh; | 624 | struct buffer_head *tmp = *dx_root_bh; |
624 | 625 | ||
625 | ret = ocfs2_read_block(dir, blkno, &tmp, ocfs2_validate_dx_root); | 626 | ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp, |
627 | ocfs2_validate_dx_root); | ||
626 | 628 | ||
627 | /* If ocfs2_read_block() got us a new bh, pass it up. */ | 629 | /* If ocfs2_read_block() got us a new bh, pass it up. */ |
628 | if (!ret && !*dx_root_bh) | 630 | if (!ret && !*dx_root_bh) |
@@ -662,7 +664,8 @@ static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno, | |||
662 | int ret; | 664 | int ret; |
663 | struct buffer_head *tmp = *dx_leaf_bh; | 665 | struct buffer_head *tmp = *dx_leaf_bh; |
664 | 666 | ||
665 | ret = ocfs2_read_block(dir, blkno, &tmp, ocfs2_validate_dx_leaf); | 667 | ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp, |
668 | ocfs2_validate_dx_leaf); | ||
666 | 669 | ||
667 | /* If ocfs2_read_block() got us a new bh, pass it up. */ | 670 | /* If ocfs2_read_block() got us a new bh, pass it up. */ |
668 | if (!ret && !*dx_leaf_bh) | 671 | if (!ret && !*dx_leaf_bh) |
@@ -680,7 +683,7 @@ static int ocfs2_read_dx_leaves(struct inode *dir, u64 start, int num, | |||
680 | { | 683 | { |
681 | int ret; | 684 | int ret; |
682 | 685 | ||
683 | ret = ocfs2_read_blocks(dir, start, num, dx_leaf_bhs, 0, | 686 | ret = ocfs2_read_blocks(INODE_CACHE(dir), start, num, dx_leaf_bhs, 0, |
684 | ocfs2_validate_dx_leaf); | 687 | ocfs2_validate_dx_leaf); |
685 | if (ret) | 688 | if (ret) |
686 | mlog_errno(ret); | 689 | mlog_errno(ret); |
@@ -2332,7 +2335,7 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb, | |||
2332 | goto bail; | 2335 | goto bail; |
2333 | } | 2336 | } |
2334 | 2337 | ||
2335 | ocfs2_set_new_buffer_uptodate(inode, new_bh); | 2338 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh); |
2336 | 2339 | ||
2337 | status = ocfs2_journal_access_db(handle, inode, new_bh, | 2340 | status = ocfs2_journal_access_db(handle, inode, new_bh, |
2338 | OCFS2_JOURNAL_ACCESS_CREATE); | 2341 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -2418,7 +2421,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb, | |||
2418 | ret = -EIO; | 2421 | ret = -EIO; |
2419 | goto out; | 2422 | goto out; |
2420 | } | 2423 | } |
2421 | ocfs2_set_new_buffer_uptodate(dir, dx_root_bh); | 2424 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dx_root_bh); |
2422 | 2425 | ||
2423 | ret = ocfs2_journal_access_dr(handle, dir, dx_root_bh, | 2426 | ret = ocfs2_journal_access_dr(handle, dir, dx_root_bh, |
2424 | OCFS2_JOURNAL_ACCESS_CREATE); | 2427 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -2495,7 +2498,7 @@ static int ocfs2_dx_dir_format_cluster(struct ocfs2_super *osb, | |||
2495 | } | 2498 | } |
2496 | dx_leaves[i] = bh; | 2499 | dx_leaves[i] = bh; |
2497 | 2500 | ||
2498 | ocfs2_set_new_buffer_uptodate(dir, bh); | 2501 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), bh); |
2499 | 2502 | ||
2500 | ret = ocfs2_journal_access_dl(handle, dir, bh, | 2503 | ret = ocfs2_journal_access_dl(handle, dir, bh, |
2501 | OCFS2_JOURNAL_ACCESS_CREATE); | 2504 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -3005,7 +3008,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, | |||
3005 | goto out_commit; | 3008 | goto out_commit; |
3006 | } | 3009 | } |
3007 | 3010 | ||
3008 | ocfs2_set_new_buffer_uptodate(dir, dirdata_bh); | 3011 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dirdata_bh); |
3009 | 3012 | ||
3010 | ret = ocfs2_journal_access_db(handle, dir, dirdata_bh, | 3013 | ret = ocfs2_journal_access_db(handle, dir, dirdata_bh, |
3011 | OCFS2_JOURNAL_ACCESS_CREATE); | 3014 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -3387,7 +3390,7 @@ do_extend: | |||
3387 | goto bail; | 3390 | goto bail; |
3388 | } | 3391 | } |
3389 | 3392 | ||
3390 | ocfs2_set_new_buffer_uptodate(dir, new_bh); | 3393 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), new_bh); |
3391 | 3394 | ||
3392 | status = ocfs2_journal_access_db(handle, dir, new_bh, | 3395 | status = ocfs2_journal_access_db(handle, dir, new_bh, |
3393 | OCFS2_JOURNAL_ACCESS_CREATE); | 3396 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -4565,7 +4568,7 @@ remove_index: | |||
4565 | goto out; | 4568 | goto out; |
4566 | } | 4569 | } |
4567 | 4570 | ||
4568 | ocfs2_remove_from_cache(dir, dx_root_bh); | 4571 | ocfs2_remove_from_cache(INODE_CACHE(dir), dx_root_bh); |
4569 | out: | 4572 | out: |
4570 | ocfs2_schedule_truncate_log_flush(osb, 1); | 4573 | ocfs2_schedule_truncate_log_flush(osb, 1); |
4571 | ocfs2_run_deallocs(osb, &dealloc); | 4574 | ocfs2_run_deallocs(osb, &dealloc); |
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 110bb57c46ab..fe15cee0322a 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c | |||
@@ -2127,7 +2127,7 @@ static int ocfs2_inode_lock_update(struct inode *inode, | |||
2127 | 2127 | ||
2128 | /* This will discard any caching information we might have had | 2128 | /* This will discard any caching information we might have had |
2129 | * for the inode metadata. */ | 2129 | * for the inode metadata. */ |
2130 | ocfs2_metadata_cache_purge(inode); | 2130 | ocfs2_metadata_cache_purge(INODE_CACHE(inode)); |
2131 | 2131 | ||
2132 | ocfs2_extent_map_trunc(inode, 0); | 2132 | ocfs2_extent_map_trunc(inode, 0); |
2133 | 2133 | ||
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index f2bb1a04d253..dbd8a16d5125 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c | |||
@@ -862,8 +862,8 @@ int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr, | |||
862 | BUG_ON(bhs[done + i]->b_blocknr != (p_block + i)); | 862 | BUG_ON(bhs[done + i]->b_blocknr != (p_block + i)); |
863 | } | 863 | } |
864 | 864 | ||
865 | rc = ocfs2_read_blocks(inode, p_block, count, bhs + done, | 865 | rc = ocfs2_read_blocks(INODE_CACHE(inode), p_block, count, |
866 | flags, validate); | 866 | bhs + done, flags, validate); |
867 | if (rc) { | 867 | if (rc) { |
868 | mlog_errno(rc); | 868 | mlog_errno(rc); |
869 | break; | 869 | break; |
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 36bb588f8fcb..1c9713cceb39 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -662,7 +662,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
662 | goto bail_commit; | 662 | goto bail_commit; |
663 | } | 663 | } |
664 | 664 | ||
665 | ocfs2_remove_from_cache(inode, di_bh); | 665 | ocfs2_remove_from_cache(INODE_CACHE(inode), di_bh); |
666 | vfs_dq_free_inode(inode); | 666 | vfs_dq_free_inode(inode); |
667 | 667 | ||
668 | status = ocfs2_free_dinode(handle, inode_alloc_inode, | 668 | status = ocfs2_free_dinode(handle, inode_alloc_inode, |
@@ -1112,14 +1112,14 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1112 | ocfs2_lock_res_free(&oi->ip_inode_lockres); | 1112 | ocfs2_lock_res_free(&oi->ip_inode_lockres); |
1113 | ocfs2_lock_res_free(&oi->ip_open_lockres); | 1113 | ocfs2_lock_res_free(&oi->ip_open_lockres); |
1114 | 1114 | ||
1115 | ocfs2_metadata_cache_purge(inode); | 1115 | ocfs2_metadata_cache_purge(INODE_CACHE(inode)); |
1116 | 1116 | ||
1117 | mlog_bug_on_msg(oi->ip_metadata_cache.ci_num_cached, | 1117 | mlog_bug_on_msg(INODE_CACHE(inode)->ci_num_cached, |
1118 | "Clear inode of %llu, inode has %u cache items\n", | 1118 | "Clear inode of %llu, inode has %u cache items\n", |
1119 | (unsigned long long)oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached); | 1119 | (unsigned long long)oi->ip_blkno, |
1120 | INODE_CACHE(inode)->ci_num_cached); | ||
1120 | 1121 | ||
1121 | mlog_bug_on_msg(!(oi->ip_metadata_cache.ci_flags & | 1122 | mlog_bug_on_msg(!(INODE_CACHE(inode)->ci_flags & OCFS2_CACHE_FL_INLINE), |
1122 | OCFS2_CACHE_FL_INLINE), | ||
1123 | "Clear inode of %llu, inode has a bad flag\n", | 1123 | "Clear inode of %llu, inode has a bad flag\n", |
1124 | (unsigned long long)oi->ip_blkno); | 1124 | (unsigned long long)oi->ip_blkno); |
1125 | 1125 | ||
@@ -1381,8 +1381,8 @@ int ocfs2_read_inode_block_full(struct inode *inode, struct buffer_head **bh, | |||
1381 | int rc; | 1381 | int rc; |
1382 | struct buffer_head *tmp = *bh; | 1382 | struct buffer_head *tmp = *bh; |
1383 | 1383 | ||
1384 | rc = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, &tmp, | 1384 | rc = ocfs2_read_blocks(INODE_CACHE(inode), OCFS2_I(inode)->ip_blkno, |
1385 | flags, ocfs2_validate_inode_block); | 1385 | 1, &tmp, flags, ocfs2_validate_inode_block); |
1386 | 1386 | ||
1387 | /* If ocfs2_read_blocks() got us a new bh, pass it up. */ | 1387 | /* If ocfs2_read_blocks() got us a new bh, pass it up. */ |
1388 | if (!rc && !*bh) | 1388 | if (!rc && !*bh) |
@@ -1408,6 +1408,13 @@ static u64 ocfs2_inode_cache_owner(struct ocfs2_caching_info *ci) | |||
1408 | return oi->ip_blkno; | 1408 | return oi->ip_blkno; |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | static struct super_block *ocfs2_inode_cache_get_super(struct ocfs2_caching_info *ci) | ||
1412 | { | ||
1413 | struct ocfs2_inode_info *oi = cache_info_to_inode(ci); | ||
1414 | |||
1415 | return oi->vfs_inode.i_sb; | ||
1416 | } | ||
1417 | |||
1411 | static void ocfs2_inode_cache_lock(struct ocfs2_caching_info *ci) | 1418 | static void ocfs2_inode_cache_lock(struct ocfs2_caching_info *ci) |
1412 | { | 1419 | { |
1413 | struct ocfs2_inode_info *oi = cache_info_to_inode(ci); | 1420 | struct ocfs2_inode_info *oi = cache_info_to_inode(ci); |
@@ -1438,6 +1445,7 @@ static void ocfs2_inode_cache_io_unlock(struct ocfs2_caching_info *ci) | |||
1438 | 1445 | ||
1439 | const struct ocfs2_caching_operations ocfs2_inode_caching_ops = { | 1446 | const struct ocfs2_caching_operations ocfs2_inode_caching_ops = { |
1440 | .co_owner = ocfs2_inode_cache_owner, | 1447 | .co_owner = ocfs2_inode_cache_owner, |
1448 | .co_get_super = ocfs2_inode_cache_get_super, | ||
1441 | .co_cache_lock = ocfs2_inode_cache_lock, | 1449 | .co_cache_lock = ocfs2_inode_cache_lock, |
1442 | .co_cache_unlock = ocfs2_inode_cache_unlock, | 1450 | .co_cache_unlock = ocfs2_inode_cache_unlock, |
1443 | .co_io_lock = ocfs2_inode_cache_io_lock, | 1451 | .co_io_lock = ocfs2_inode_cache_io_lock, |
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h index cd1caca545f5..b0a71b22712c 100644 --- a/fs/ocfs2/inode.h +++ b/fs/ocfs2/inode.h | |||
@@ -120,6 +120,11 @@ extern struct kmem_cache *ocfs2_inode_cache; | |||
120 | extern const struct address_space_operations ocfs2_aops; | 120 | extern const struct address_space_operations ocfs2_aops; |
121 | extern const struct ocfs2_caching_operations ocfs2_inode_caching_ops; | 121 | extern const struct ocfs2_caching_operations ocfs2_inode_caching_ops; |
122 | 122 | ||
123 | static inline struct ocfs2_caching_info *INODE_CACHE(struct inode *inode) | ||
124 | { | ||
125 | return &OCFS2_I(inode)->ip_metadata_cache; | ||
126 | } | ||
127 | |||
123 | void ocfs2_clear_inode(struct inode *inode); | 128 | void ocfs2_clear_inode(struct inode *inode); |
124 | void ocfs2_delete_inode(struct inode *inode); | 129 | void ocfs2_delete_inode(struct inode *inode); |
125 | void ocfs2_drop_inode(struct inode *inode); | 130 | void ocfs2_drop_inode(struct inode *inode); |
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index c48b93ac6b65..ddf08d384ba1 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
@@ -898,7 +898,7 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, | |||
898 | ocfs2_bump_recovery_generation(fe); | 898 | ocfs2_bump_recovery_generation(fe); |
899 | 899 | ||
900 | ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check); | 900 | ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check); |
901 | status = ocfs2_write_block(osb, bh, journal->j_inode); | 901 | status = ocfs2_write_block(osb, bh, INODE_CACHE(journal->j_inode)); |
902 | if (status < 0) | 902 | if (status < 0) |
903 | mlog_errno(status); | 903 | mlog_errno(status); |
904 | 904 | ||
@@ -1642,7 +1642,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
1642 | ocfs2_get_recovery_generation(fe); | 1642 | ocfs2_get_recovery_generation(fe); |
1643 | 1643 | ||
1644 | ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check); | 1644 | ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check); |
1645 | status = ocfs2_write_block(osb, bh, inode); | 1645 | status = ocfs2_write_block(osb, bh, INODE_CACHE(inode)); |
1646 | if (status < 0) | 1646 | if (status < 0) |
1647 | mlog_errno(status); | 1647 | mlog_errno(status); |
1648 | 1648 | ||
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index bac7e6abaf47..da5dd6a70e16 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -392,7 +392,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, | |||
392 | ocfs2_clear_local_alloc(alloc); | 392 | ocfs2_clear_local_alloc(alloc); |
393 | 393 | ||
394 | ocfs2_compute_meta_ecc(osb->sb, alloc_bh->b_data, &alloc->i_check); | 394 | ocfs2_compute_meta_ecc(osb->sb, alloc_bh->b_data, &alloc->i_check); |
395 | status = ocfs2_write_block(osb, alloc_bh, inode); | 395 | status = ocfs2_write_block(osb, alloc_bh, INODE_CACHE(inode)); |
396 | if (status < 0) | 396 | if (status < 0) |
397 | mlog_errno(status); | 397 | mlog_errno(status); |
398 | 398 | ||
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 8601f934010b..689761b57a18 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -507,7 +507,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
507 | mlog_errno(status); | 507 | mlog_errno(status); |
508 | goto leave; | 508 | goto leave; |
509 | } | 509 | } |
510 | ocfs2_set_new_buffer_uptodate(inode, *new_fe_bh); | 510 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), *new_fe_bh); |
511 | 511 | ||
512 | status = ocfs2_journal_access_di(handle, inode, *new_fe_bh, | 512 | status = ocfs2_journal_access_di(handle, inode, *new_fe_bh, |
513 | OCFS2_JOURNAL_ACCESS_CREATE); | 513 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -1527,7 +1527,8 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | |||
1527 | mlog_errno(status); | 1527 | mlog_errno(status); |
1528 | goto bail; | 1528 | goto bail; |
1529 | } | 1529 | } |
1530 | ocfs2_set_new_buffer_uptodate(inode, bhs[virtual]); | 1530 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), |
1531 | bhs[virtual]); | ||
1531 | 1532 | ||
1532 | status = ocfs2_journal_access(handle, inode, bhs[virtual], | 1533 | status = ocfs2_journal_access(handle, inode, bhs[virtual], |
1533 | OCFS2_JOURNAL_ACCESS_CREATE); | 1534 | OCFS2_JOURNAL_ACCESS_CREATE); |
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c index 44f2a5e1d042..0d7125bb71d9 100644 --- a/fs/ocfs2/quota_global.c +++ b/fs/ocfs2/quota_global.c | |||
@@ -253,7 +253,7 @@ ssize_t ocfs2_quota_write(struct super_block *sb, int type, | |||
253 | flush_dcache_page(bh->b_page); | 253 | flush_dcache_page(bh->b_page); |
254 | set_buffer_uptodate(bh); | 254 | set_buffer_uptodate(bh); |
255 | unlock_buffer(bh); | 255 | unlock_buffer(bh); |
256 | ocfs2_set_buffer_uptodate(gqinode, bh); | 256 | ocfs2_set_buffer_uptodate(INODE_CACHE(gqinode), bh); |
257 | err = ocfs2_journal_access_dq(handle, gqinode, bh, ja_type); | 257 | err = ocfs2_journal_access_dq(handle, gqinode, bh, ja_type); |
258 | if (err < 0) { | 258 | if (err < 0) { |
259 | brelse(bh); | 259 | brelse(bh); |
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c index bdb09cb6e1fe..3df2954ac83b 100644 --- a/fs/ocfs2/quota_local.c +++ b/fs/ocfs2/quota_local.c | |||
@@ -993,7 +993,7 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk( | |||
993 | goto out_trans; | 993 | goto out_trans; |
994 | } | 994 | } |
995 | dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data; | 995 | dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data; |
996 | ocfs2_set_new_buffer_uptodate(lqinode, bh); | 996 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(lqinode), bh); |
997 | status = ocfs2_journal_access_dq(handle, lqinode, bh, | 997 | status = ocfs2_journal_access_dq(handle, lqinode, bh, |
998 | OCFS2_JOURNAL_ACCESS_CREATE); | 998 | OCFS2_JOURNAL_ACCESS_CREATE); |
999 | if (status < 0) { | 999 | if (status < 0) { |
@@ -1027,7 +1027,7 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk( | |||
1027 | mlog_errno(status); | 1027 | mlog_errno(status); |
1028 | goto out_trans; | 1028 | goto out_trans; |
1029 | } | 1029 | } |
1030 | ocfs2_set_new_buffer_uptodate(lqinode, dbh); | 1030 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(lqinode), dbh); |
1031 | status = ocfs2_journal_access_dq(handle, lqinode, dbh, | 1031 | status = ocfs2_journal_access_dq(handle, lqinode, dbh, |
1032 | OCFS2_JOURNAL_ACCESS_CREATE); | 1032 | OCFS2_JOURNAL_ACCESS_CREATE); |
1033 | if (status < 0) { | 1033 | if (status < 0) { |
@@ -1131,7 +1131,7 @@ static struct ocfs2_quota_chunk *ocfs2_extend_local_quota_file( | |||
1131 | mlog_errno(status); | 1131 | mlog_errno(status); |
1132 | goto out; | 1132 | goto out; |
1133 | } | 1133 | } |
1134 | ocfs2_set_new_buffer_uptodate(lqinode, bh); | 1134 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(lqinode), bh); |
1135 | 1135 | ||
1136 | /* Local quota info, chunk header and the new block we initialize */ | 1136 | /* Local quota info, chunk header and the new block we initialize */ |
1137 | handle = ocfs2_start_trans(OCFS2_SB(sb), | 1137 | handle = ocfs2_start_trans(OCFS2_SB(sb), |
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c index 424adaa5f900..7465f0fded77 100644 --- a/fs/ocfs2/resize.c +++ b/fs/ocfs2/resize.c | |||
@@ -514,7 +514,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) | |||
514 | goto out_unlock; | 514 | goto out_unlock; |
515 | } | 515 | } |
516 | 516 | ||
517 | ocfs2_set_new_buffer_uptodate(inode, group_bh); | 517 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), group_bh); |
518 | 518 | ||
519 | ret = ocfs2_verify_group_and_input(main_bm_inode, fe, input, group_bh); | 519 | ret = ocfs2_verify_group_and_input(main_bm_inode, fe, input, group_bh); |
520 | if (ret) { | 520 | if (ret) { |
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index 40661e7824e9..bfbd7e9e949f 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c | |||
@@ -150,8 +150,8 @@ int ocfs2_refresh_slot_info(struct ocfs2_super *osb) | |||
150 | * be !NULL. Thus, ocfs2_read_blocks() will ignore blocknr. If | 150 | * be !NULL. Thus, ocfs2_read_blocks() will ignore blocknr. If |
151 | * this is not true, the read of -1 (UINT64_MAX) will fail. | 151 | * this is not true, the read of -1 (UINT64_MAX) will fail. |
152 | */ | 152 | */ |
153 | ret = ocfs2_read_blocks(si->si_inode, -1, si->si_blocks, si->si_bh, | 153 | ret = ocfs2_read_blocks(INODE_CACHE(si->si_inode), -1, si->si_blocks, |
154 | OCFS2_BH_IGNORE_CACHE, NULL); | 154 | si->si_bh, OCFS2_BH_IGNORE_CACHE, NULL); |
155 | if (ret == 0) { | 155 | if (ret == 0) { |
156 | spin_lock(&osb->osb_lock); | 156 | spin_lock(&osb->osb_lock); |
157 | ocfs2_update_slot_info(si); | 157 | ocfs2_update_slot_info(si); |
@@ -213,7 +213,7 @@ static int ocfs2_update_disk_slot(struct ocfs2_super *osb, | |||
213 | ocfs2_update_disk_slot_old(si, slot_num, &bh); | 213 | ocfs2_update_disk_slot_old(si, slot_num, &bh); |
214 | spin_unlock(&osb->osb_lock); | 214 | spin_unlock(&osb->osb_lock); |
215 | 215 | ||
216 | status = ocfs2_write_block(osb, bh, si->si_inode); | 216 | status = ocfs2_write_block(osb, bh, INODE_CACHE(si->si_inode)); |
217 | if (status < 0) | 217 | if (status < 0) |
218 | mlog_errno(status); | 218 | mlog_errno(status); |
219 | 219 | ||
@@ -404,8 +404,8 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb, | |||
404 | (unsigned long long)blkno); | 404 | (unsigned long long)blkno); |
405 | 405 | ||
406 | bh = NULL; /* Acquire a fresh bh */ | 406 | bh = NULL; /* Acquire a fresh bh */ |
407 | status = ocfs2_read_blocks(si->si_inode, blkno, 1, &bh, | 407 | status = ocfs2_read_blocks(INODE_CACHE(si->si_inode), blkno, |
408 | OCFS2_BH_IGNORE_CACHE, NULL); | 408 | 1, &bh, OCFS2_BH_IGNORE_CACHE, NULL); |
409 | if (status < 0) { | 409 | if (status < 0) { |
410 | mlog_errno(status); | 410 | mlog_errno(status); |
411 | goto bail; | 411 | goto bail; |
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 73a16d4666dc..21aaaaaaa2d3 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
@@ -310,7 +310,7 @@ int ocfs2_read_group_descriptor(struct inode *inode, struct ocfs2_dinode *di, | |||
310 | int rc; | 310 | int rc; |
311 | struct buffer_head *tmp = *bh; | 311 | struct buffer_head *tmp = *bh; |
312 | 312 | ||
313 | rc = ocfs2_read_block(inode, gd_blkno, &tmp, | 313 | rc = ocfs2_read_block(INODE_CACHE(inode), gd_blkno, &tmp, |
314 | ocfs2_validate_group_descriptor); | 314 | ocfs2_validate_group_descriptor); |
315 | if (rc) | 315 | if (rc) |
316 | goto out; | 316 | goto out; |
@@ -476,7 +476,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
476 | mlog_errno(status); | 476 | mlog_errno(status); |
477 | goto bail; | 477 | goto bail; |
478 | } | 478 | } |
479 | ocfs2_set_new_buffer_uptodate(alloc_inode, bg_bh); | 479 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(alloc_inode), bg_bh); |
480 | 480 | ||
481 | status = ocfs2_block_group_fill(handle, | 481 | status = ocfs2_block_group_fill(handle, |
482 | alloc_inode, | 482 | alloc_inode, |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 746ed5d4dda9..af118ad98c58 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -1683,7 +1683,7 @@ static void ocfs2_inode_init_once(void *data) | |||
1683 | ocfs2_lock_res_init_once(&oi->ip_inode_lockres); | 1683 | ocfs2_lock_res_init_once(&oi->ip_inode_lockres); |
1684 | ocfs2_lock_res_init_once(&oi->ip_open_lockres); | 1684 | ocfs2_lock_res_init_once(&oi->ip_open_lockres); |
1685 | 1685 | ||
1686 | ocfs2_metadata_cache_init(&oi->ip_metadata_cache, | 1686 | ocfs2_metadata_cache_init(INODE_CACHE(&oi->vfs_inode), |
1687 | &ocfs2_inode_caching_ops); | 1687 | &ocfs2_inode_caching_ops); |
1688 | 1688 | ||
1689 | inode_init_once(&oi->vfs_inode); | 1689 | inode_init_once(&oi->vfs_inode); |
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c index 226d0429fd7f..1c829e451019 100644 --- a/fs/ocfs2/uptodate.c +++ b/fs/ocfs2/uptodate.c | |||
@@ -75,13 +75,20 @@ struct ocfs2_meta_cache_item { | |||
75 | 75 | ||
76 | static struct kmem_cache *ocfs2_uptodate_cachep = NULL; | 76 | static struct kmem_cache *ocfs2_uptodate_cachep = NULL; |
77 | 77 | ||
78 | static u64 ocfs2_metadata_cache_owner(struct ocfs2_caching_info *ci) | 78 | u64 ocfs2_metadata_cache_owner(struct ocfs2_caching_info *ci) |
79 | { | 79 | { |
80 | BUG_ON(!ci || !ci->ci_ops); | 80 | BUG_ON(!ci || !ci->ci_ops); |
81 | 81 | ||
82 | return ci->ci_ops->co_owner(ci); | 82 | return ci->ci_ops->co_owner(ci); |
83 | } | 83 | } |
84 | 84 | ||
85 | struct super_block *ocfs2_metadata_cache_get_super(struct ocfs2_caching_info *ci) | ||
86 | { | ||
87 | BUG_ON(!ci || !ci->ci_ops); | ||
88 | |||
89 | return ci->ci_ops->co_get_super(ci); | ||
90 | } | ||
91 | |||
85 | static void ocfs2_metadata_cache_lock(struct ocfs2_caching_info *ci) | 92 | static void ocfs2_metadata_cache_lock(struct ocfs2_caching_info *ci) |
86 | { | 93 | { |
87 | BUG_ON(!ci || !ci->ci_ops); | 94 | BUG_ON(!ci || !ci->ci_ops); |
@@ -96,14 +103,14 @@ static void ocfs2_metadata_cache_unlock(struct ocfs2_caching_info *ci) | |||
96 | ci->ci_ops->co_cache_unlock(ci); | 103 | ci->ci_ops->co_cache_unlock(ci); |
97 | } | 104 | } |
98 | 105 | ||
99 | static void ocfs2_metadata_cache_io_lock(struct ocfs2_caching_info *ci) | 106 | void ocfs2_metadata_cache_io_lock(struct ocfs2_caching_info *ci) |
100 | { | 107 | { |
101 | BUG_ON(!ci || !ci->ci_ops); | 108 | BUG_ON(!ci || !ci->ci_ops); |
102 | 109 | ||
103 | ci->ci_ops->co_io_lock(ci); | 110 | ci->ci_ops->co_io_lock(ci); |
104 | } | 111 | } |
105 | 112 | ||
106 | static void ocfs2_metadata_cache_io_unlock(struct ocfs2_caching_info *ci) | 113 | void ocfs2_metadata_cache_io_unlock(struct ocfs2_caching_info *ci) |
107 | { | 114 | { |
108 | BUG_ON(!ci || !ci->ci_ops); | 115 | BUG_ON(!ci || !ci->ci_ops); |
109 | 116 | ||
@@ -149,11 +156,9 @@ static unsigned int ocfs2_purge_copied_metadata_tree(struct rb_root *root) | |||
149 | * This function is a few more lines longer than necessary due to some | 156 | * This function is a few more lines longer than necessary due to some |
150 | * accounting done here, but I think it's worth tracking down those | 157 | * accounting done here, but I think it's worth tracking down those |
151 | * bugs sooner -- Mark */ | 158 | * bugs sooner -- Mark */ |
152 | void ocfs2_metadata_cache_purge(struct inode *inode) | 159 | void ocfs2_metadata_cache_purge(struct ocfs2_caching_info *ci) |
153 | { | 160 | { |
154 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
155 | unsigned int tree, to_purge, purged; | 161 | unsigned int tree, to_purge, purged; |
156 | struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; | ||
157 | struct rb_root root = RB_ROOT; | 162 | struct rb_root root = RB_ROOT; |
158 | 163 | ||
159 | BUG_ON(!ci || !ci->ci_ops); | 164 | BUG_ON(!ci || !ci->ci_ops); |
@@ -223,12 +228,11 @@ ocfs2_search_cache_tree(struct ocfs2_caching_info *ci, | |||
223 | return NULL; | 228 | return NULL; |
224 | } | 229 | } |
225 | 230 | ||
226 | static int ocfs2_buffer_cached(struct ocfs2_inode_info *oi, | 231 | static int ocfs2_buffer_cached(struct ocfs2_caching_info *ci, |
227 | struct buffer_head *bh) | 232 | struct buffer_head *bh) |
228 | { | 233 | { |
229 | int index = -1; | 234 | int index = -1; |
230 | struct ocfs2_meta_cache_item *item = NULL; | 235 | struct ocfs2_meta_cache_item *item = NULL; |
231 | struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; | ||
232 | 236 | ||
233 | ocfs2_metadata_cache_lock(ci); | 237 | ocfs2_metadata_cache_lock(ci); |
234 | 238 | ||
@@ -238,11 +242,9 @@ static int ocfs2_buffer_cached(struct ocfs2_inode_info *oi, | |||
238 | !!(ci->ci_flags & OCFS2_CACHE_FL_INLINE)); | 242 | !!(ci->ci_flags & OCFS2_CACHE_FL_INLINE)); |
239 | 243 | ||
240 | if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) | 244 | if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) |
241 | index = ocfs2_search_cache_array(&oi->ip_metadata_cache, | 245 | index = ocfs2_search_cache_array(ci, bh->b_blocknr); |
242 | bh->b_blocknr); | ||
243 | else | 246 | else |
244 | item = ocfs2_search_cache_tree(&oi->ip_metadata_cache, | 247 | item = ocfs2_search_cache_tree(ci, bh->b_blocknr); |
245 | bh->b_blocknr); | ||
246 | 248 | ||
247 | ocfs2_metadata_cache_unlock(ci); | 249 | ocfs2_metadata_cache_unlock(ci); |
248 | 250 | ||
@@ -256,7 +258,7 @@ static int ocfs2_buffer_cached(struct ocfs2_inode_info *oi, | |||
256 | * | 258 | * |
257 | * This can be called under lock_buffer() | 259 | * This can be called under lock_buffer() |
258 | */ | 260 | */ |
259 | int ocfs2_buffer_uptodate(struct inode *inode, | 261 | int ocfs2_buffer_uptodate(struct ocfs2_caching_info *ci, |
260 | struct buffer_head *bh) | 262 | struct buffer_head *bh) |
261 | { | 263 | { |
262 | /* Doesn't matter if the bh is in our cache or not -- if it's | 264 | /* Doesn't matter if the bh is in our cache or not -- if it's |
@@ -272,17 +274,17 @@ int ocfs2_buffer_uptodate(struct inode *inode, | |||
272 | 274 | ||
273 | /* Ok, locally the buffer is marked as up to date, now search | 275 | /* Ok, locally the buffer is marked as up to date, now search |
274 | * our cache to see if we can trust that. */ | 276 | * our cache to see if we can trust that. */ |
275 | return ocfs2_buffer_cached(OCFS2_I(inode), bh); | 277 | return ocfs2_buffer_cached(ci, bh); |
276 | } | 278 | } |
277 | 279 | ||
278 | /* | 280 | /* |
279 | * Determine whether a buffer is currently out on a read-ahead request. | 281 | * Determine whether a buffer is currently out on a read-ahead request. |
280 | * ci_io_sem should be held to serialize submitters with the logic here. | 282 | * ci_io_sem should be held to serialize submitters with the logic here. |
281 | */ | 283 | */ |
282 | int ocfs2_buffer_read_ahead(struct inode *inode, | 284 | int ocfs2_buffer_read_ahead(struct ocfs2_caching_info *ci, |
283 | struct buffer_head *bh) | 285 | struct buffer_head *bh) |
284 | { | 286 | { |
285 | return buffer_locked(bh) && ocfs2_buffer_cached(OCFS2_I(inode), bh); | 287 | return buffer_locked(bh) && ocfs2_buffer_cached(ci, bh); |
286 | } | 288 | } |
287 | 289 | ||
288 | /* Requires ip_lock */ | 290 | /* Requires ip_lock */ |
@@ -335,8 +337,7 @@ static void __ocfs2_insert_cache_tree(struct ocfs2_caching_info *ci, | |||
335 | } | 337 | } |
336 | 338 | ||
337 | /* co_cache_lock() must be held */ | 339 | /* co_cache_lock() must be held */ |
338 | static inline int ocfs2_insert_can_use_array(struct ocfs2_inode_info *oi, | 340 | static inline int ocfs2_insert_can_use_array(struct ocfs2_caching_info *ci) |
339 | struct ocfs2_caching_info *ci) | ||
340 | { | 341 | { |
341 | return (ci->ci_flags & OCFS2_CACHE_FL_INLINE) && | 342 | return (ci->ci_flags & OCFS2_CACHE_FL_INLINE) && |
342 | (ci->ci_num_cached < OCFS2_CACHE_INFO_MAX_ARRAY); | 343 | (ci->ci_num_cached < OCFS2_CACHE_INFO_MAX_ARRAY); |
@@ -347,11 +348,10 @@ static inline int ocfs2_insert_can_use_array(struct ocfs2_inode_info *oi, | |||
347 | * when to free in case of error. | 348 | * when to free in case of error. |
348 | * | 349 | * |
349 | * The co_cache_lock() must be held. */ | 350 | * The co_cache_lock() must be held. */ |
350 | static void ocfs2_expand_cache(struct ocfs2_inode_info *oi, | 351 | static void ocfs2_expand_cache(struct ocfs2_caching_info *ci, |
351 | struct ocfs2_meta_cache_item **tree) | 352 | struct ocfs2_meta_cache_item **tree) |
352 | { | 353 | { |
353 | int i; | 354 | int i; |
354 | struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; | ||
355 | 355 | ||
356 | mlog_bug_on_msg(ci->ci_num_cached != OCFS2_CACHE_INFO_MAX_ARRAY, | 356 | mlog_bug_on_msg(ci->ci_num_cached != OCFS2_CACHE_INFO_MAX_ARRAY, |
357 | "Owner %llu, num cached = %u, should be %u\n", | 357 | "Owner %llu, num cached = %u, should be %u\n", |
@@ -383,12 +383,11 @@ static void ocfs2_expand_cache(struct ocfs2_inode_info *oi, | |||
383 | 383 | ||
384 | /* Slow path function - memory allocation is necessary. See the | 384 | /* Slow path function - memory allocation is necessary. See the |
385 | * comment above ocfs2_set_buffer_uptodate for more information. */ | 385 | * comment above ocfs2_set_buffer_uptodate for more information. */ |
386 | static void __ocfs2_set_buffer_uptodate(struct ocfs2_inode_info *oi, | 386 | static void __ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, |
387 | sector_t block, | 387 | sector_t block, |
388 | int expand_tree) | 388 | int expand_tree) |
389 | { | 389 | { |
390 | int i; | 390 | int i; |
391 | struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; | ||
392 | struct ocfs2_meta_cache_item *new = NULL; | 391 | struct ocfs2_meta_cache_item *new = NULL; |
393 | struct ocfs2_meta_cache_item *tree[OCFS2_CACHE_INFO_MAX_ARRAY] = | 392 | struct ocfs2_meta_cache_item *tree[OCFS2_CACHE_INFO_MAX_ARRAY] = |
394 | { NULL, }; | 393 | { NULL, }; |
@@ -420,7 +419,7 @@ static void __ocfs2_set_buffer_uptodate(struct ocfs2_inode_info *oi, | |||
420 | } | 419 | } |
421 | 420 | ||
422 | ocfs2_metadata_cache_lock(ci); | 421 | ocfs2_metadata_cache_lock(ci); |
423 | if (ocfs2_insert_can_use_array(oi, ci)) { | 422 | if (ocfs2_insert_can_use_array(ci)) { |
424 | mlog(0, "Someone cleared the tree underneath us\n"); | 423 | mlog(0, "Someone cleared the tree underneath us\n"); |
425 | /* Ok, items were removed from the cache in between | 424 | /* Ok, items were removed from the cache in between |
426 | * locks. Detect this and revert back to the fast path */ | 425 | * locks. Detect this and revert back to the fast path */ |
@@ -430,7 +429,7 @@ static void __ocfs2_set_buffer_uptodate(struct ocfs2_inode_info *oi, | |||
430 | } | 429 | } |
431 | 430 | ||
432 | if (expand_tree) | 431 | if (expand_tree) |
433 | ocfs2_expand_cache(oi, tree); | 432 | ocfs2_expand_cache(ci, tree); |
434 | 433 | ||
435 | __ocfs2_insert_cache_tree(ci, new); | 434 | __ocfs2_insert_cache_tree(ci, new); |
436 | ocfs2_metadata_cache_unlock(ci); | 435 | ocfs2_metadata_cache_unlock(ci); |
@@ -468,16 +467,14 @@ out_free: | |||
468 | * Readahead buffers can be passed in here before the I/O request is | 467 | * Readahead buffers can be passed in here before the I/O request is |
469 | * completed. | 468 | * completed. |
470 | */ | 469 | */ |
471 | void ocfs2_set_buffer_uptodate(struct inode *inode, | 470 | void ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, |
472 | struct buffer_head *bh) | 471 | struct buffer_head *bh) |
473 | { | 472 | { |
474 | int expand; | 473 | int expand; |
475 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
476 | struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; | ||
477 | 474 | ||
478 | /* The block may very well exist in our cache already, so avoid | 475 | /* The block may very well exist in our cache already, so avoid |
479 | * doing any more work in that case. */ | 476 | * doing any more work in that case. */ |
480 | if (ocfs2_buffer_cached(oi, bh)) | 477 | if (ocfs2_buffer_cached(ci, bh)) |
481 | return; | 478 | return; |
482 | 479 | ||
483 | mlog(0, "Owner %llu, inserting block %llu\n", | 480 | mlog(0, "Owner %llu, inserting block %llu\n", |
@@ -487,7 +484,7 @@ void ocfs2_set_buffer_uptodate(struct inode *inode, | |||
487 | /* No need to recheck under spinlock - insertion is guarded by | 484 | /* No need to recheck under spinlock - insertion is guarded by |
488 | * co_io_lock() */ | 485 | * co_io_lock() */ |
489 | ocfs2_metadata_cache_lock(ci); | 486 | ocfs2_metadata_cache_lock(ci); |
490 | if (ocfs2_insert_can_use_array(oi, ci)) { | 487 | if (ocfs2_insert_can_use_array(ci)) { |
491 | /* Fast case - it's an array and there's a free | 488 | /* Fast case - it's an array and there's a free |
492 | * spot. */ | 489 | * spot. */ |
493 | ocfs2_append_cache_array(ci, bh->b_blocknr); | 490 | ocfs2_append_cache_array(ci, bh->b_blocknr); |
@@ -502,25 +499,22 @@ void ocfs2_set_buffer_uptodate(struct inode *inode, | |||
502 | } | 499 | } |
503 | ocfs2_metadata_cache_unlock(ci); | 500 | ocfs2_metadata_cache_unlock(ci); |
504 | 501 | ||
505 | __ocfs2_set_buffer_uptodate(oi, bh->b_blocknr, expand); | 502 | __ocfs2_set_buffer_uptodate(ci, bh->b_blocknr, expand); |
506 | } | 503 | } |
507 | 504 | ||
508 | /* Called against a newly allocated buffer. Most likely nobody should | 505 | /* Called against a newly allocated buffer. Most likely nobody should |
509 | * be able to read this sort of metadata while it's still being | 506 | * be able to read this sort of metadata while it's still being |
510 | * allocated, but this is careful to take co_io_lock() anyway. */ | 507 | * allocated, but this is careful to take co_io_lock() anyway. */ |
511 | void ocfs2_set_new_buffer_uptodate(struct inode *inode, | 508 | void ocfs2_set_new_buffer_uptodate(struct ocfs2_caching_info *ci, |
512 | struct buffer_head *bh) | 509 | struct buffer_head *bh) |
513 | { | 510 | { |
514 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
515 | struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; | ||
516 | |||
517 | /* This should definitely *not* exist in our cache */ | 511 | /* This should definitely *not* exist in our cache */ |
518 | BUG_ON(ocfs2_buffer_cached(oi, bh)); | 512 | BUG_ON(ocfs2_buffer_cached(ci, bh)); |
519 | 513 | ||
520 | set_buffer_uptodate(bh); | 514 | set_buffer_uptodate(bh); |
521 | 515 | ||
522 | ocfs2_metadata_cache_io_lock(ci); | 516 | ocfs2_metadata_cache_io_lock(ci); |
523 | ocfs2_set_buffer_uptodate(inode, bh); | 517 | ocfs2_set_buffer_uptodate(ci, bh); |
524 | ocfs2_metadata_cache_io_unlock(ci); | 518 | ocfs2_metadata_cache_io_unlock(ci); |
525 | } | 519 | } |
526 | 520 | ||
@@ -559,13 +553,11 @@ static void ocfs2_remove_metadata_tree(struct ocfs2_caching_info *ci, | |||
559 | ci->ci_num_cached--; | 553 | ci->ci_num_cached--; |
560 | } | 554 | } |
561 | 555 | ||
562 | static void ocfs2_remove_block_from_cache(struct inode *inode, | 556 | static void ocfs2_remove_block_from_cache(struct ocfs2_caching_info *ci, |
563 | sector_t block) | 557 | sector_t block) |
564 | { | 558 | { |
565 | int index; | 559 | int index; |
566 | struct ocfs2_meta_cache_item *item = NULL; | 560 | struct ocfs2_meta_cache_item *item = NULL; |
567 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
568 | struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; | ||
569 | 561 | ||
570 | ocfs2_metadata_cache_lock(ci); | 562 | ocfs2_metadata_cache_lock(ci); |
571 | mlog(0, "Owner %llu, remove %llu, items = %u, array = %u\n", | 563 | mlog(0, "Owner %llu, remove %llu, items = %u, array = %u\n", |
@@ -593,23 +585,24 @@ static void ocfs2_remove_block_from_cache(struct inode *inode, | |||
593 | * bother reverting things to an inlined array in the case of a remove | 585 | * bother reverting things to an inlined array in the case of a remove |
594 | * which moves us back under the limit. | 586 | * which moves us back under the limit. |
595 | */ | 587 | */ |
596 | void ocfs2_remove_from_cache(struct inode *inode, | 588 | void ocfs2_remove_from_cache(struct ocfs2_caching_info *ci, |
597 | struct buffer_head *bh) | 589 | struct buffer_head *bh) |
598 | { | 590 | { |
599 | sector_t block = bh->b_blocknr; | 591 | sector_t block = bh->b_blocknr; |
600 | 592 | ||
601 | ocfs2_remove_block_from_cache(inode, block); | 593 | ocfs2_remove_block_from_cache(ci, block); |
602 | } | 594 | } |
603 | 595 | ||
604 | /* Called when we remove xattr clusters from an inode. */ | 596 | /* Called when we remove xattr clusters from an inode. */ |
605 | void ocfs2_remove_xattr_clusters_from_cache(struct inode *inode, | 597 | void ocfs2_remove_xattr_clusters_from_cache(struct ocfs2_caching_info *ci, |
606 | sector_t block, | 598 | sector_t block, |
607 | u32 c_len) | 599 | u32 c_len) |
608 | { | 600 | { |
609 | unsigned int i, b_len = ocfs2_clusters_to_blocks(inode->i_sb, 1) * c_len; | 601 | struct super_block *sb = ocfs2_metadata_cache_get_super(ci); |
602 | unsigned int i, b_len = ocfs2_clusters_to_blocks(sb, 1) * c_len; | ||
610 | 603 | ||
611 | for (i = 0; i < b_len; i++, block++) | 604 | for (i = 0; i < b_len; i++, block++) |
612 | ocfs2_remove_block_from_cache(inode, block); | 605 | ocfs2_remove_block_from_cache(ci, block); |
613 | } | 606 | } |
614 | 607 | ||
615 | int __init init_ocfs2_uptodate_cache(void) | 608 | int __init init_ocfs2_uptodate_cache(void) |
diff --git a/fs/ocfs2/uptodate.h b/fs/ocfs2/uptodate.h index 3b33eb88d320..f268273d6516 100644 --- a/fs/ocfs2/uptodate.h +++ b/fs/ocfs2/uptodate.h | |||
@@ -38,6 +38,8 @@ struct ocfs2_caching_operations { | |||
38 | */ | 38 | */ |
39 | u64 (*co_owner)(struct ocfs2_caching_info *ci); | 39 | u64 (*co_owner)(struct ocfs2_caching_info *ci); |
40 | 40 | ||
41 | /* The superblock is needed during I/O. */ | ||
42 | struct super_block *(*co_get_super)(struct ocfs2_caching_info *ci); | ||
41 | /* | 43 | /* |
42 | * Lock and unlock the caching data. These will not sleep, and | 44 | * Lock and unlock the caching data. These will not sleep, and |
43 | * should probably be spinlocks. | 45 | * should probably be spinlocks. |
@@ -58,20 +60,25 @@ void exit_ocfs2_uptodate_cache(void); | |||
58 | 60 | ||
59 | void ocfs2_metadata_cache_init(struct ocfs2_caching_info *ci, | 61 | void ocfs2_metadata_cache_init(struct ocfs2_caching_info *ci, |
60 | const struct ocfs2_caching_operations *ops); | 62 | const struct ocfs2_caching_operations *ops); |
61 | void ocfs2_metadata_cache_purge(struct inode *inode); | 63 | void ocfs2_metadata_cache_purge(struct ocfs2_caching_info *ci); |
62 | 64 | ||
63 | int ocfs2_buffer_uptodate(struct inode *inode, | 65 | u64 ocfs2_metadata_cache_owner(struct ocfs2_caching_info *ci); |
66 | struct super_block *ocfs2_metadata_cache_get_super(struct ocfs2_caching_info *ci); | ||
67 | void ocfs2_metadata_cache_io_lock(struct ocfs2_caching_info *ci); | ||
68 | void ocfs2_metadata_cache_io_unlock(struct ocfs2_caching_info *ci); | ||
69 | |||
70 | int ocfs2_buffer_uptodate(struct ocfs2_caching_info *ci, | ||
64 | struct buffer_head *bh); | 71 | struct buffer_head *bh); |
65 | void ocfs2_set_buffer_uptodate(struct inode *inode, | 72 | void ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, |
66 | struct buffer_head *bh); | 73 | struct buffer_head *bh); |
67 | void ocfs2_set_new_buffer_uptodate(struct inode *inode, | 74 | void ocfs2_set_new_buffer_uptodate(struct ocfs2_caching_info *ci, |
68 | struct buffer_head *bh); | 75 | struct buffer_head *bh); |
69 | void ocfs2_remove_from_cache(struct inode *inode, | 76 | void ocfs2_remove_from_cache(struct ocfs2_caching_info *ci, |
70 | struct buffer_head *bh); | 77 | struct buffer_head *bh); |
71 | void ocfs2_remove_xattr_clusters_from_cache(struct inode *inode, | 78 | void ocfs2_remove_xattr_clusters_from_cache(struct ocfs2_caching_info *ci, |
72 | sector_t block, | 79 | sector_t block, |
73 | u32 c_len); | 80 | u32 c_len); |
74 | int ocfs2_buffer_read_ahead(struct inode *inode, | 81 | int ocfs2_buffer_read_ahead(struct ocfs2_caching_info *ci, |
75 | struct buffer_head *bh); | 82 | struct buffer_head *bh); |
76 | 83 | ||
77 | #endif /* OCFS2_UPTODATE_H */ | 84 | #endif /* OCFS2_UPTODATE_H */ |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index d1a27cda984f..19de5c487242 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -254,9 +254,9 @@ static int ocfs2_init_xattr_bucket(struct ocfs2_xattr_bucket *bucket, | |||
254 | break; | 254 | break; |
255 | } | 255 | } |
256 | 256 | ||
257 | if (!ocfs2_buffer_uptodate(bucket->bu_inode, | 257 | if (!ocfs2_buffer_uptodate(INODE_CACHE(bucket->bu_inode), |
258 | bucket->bu_bhs[i])) | 258 | bucket->bu_bhs[i])) |
259 | ocfs2_set_new_buffer_uptodate(bucket->bu_inode, | 259 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(bucket->bu_inode), |
260 | bucket->bu_bhs[i]); | 260 | bucket->bu_bhs[i]); |
261 | } | 261 | } |
262 | 262 | ||
@@ -271,7 +271,7 @@ static int ocfs2_read_xattr_bucket(struct ocfs2_xattr_bucket *bucket, | |||
271 | { | 271 | { |
272 | int rc; | 272 | int rc; |
273 | 273 | ||
274 | rc = ocfs2_read_blocks(bucket->bu_inode, xb_blkno, | 274 | rc = ocfs2_read_blocks(INODE_CACHE(bucket->bu_inode), xb_blkno, |
275 | bucket->bu_blocks, bucket->bu_bhs, 0, | 275 | bucket->bu_blocks, bucket->bu_bhs, 0, |
276 | NULL); | 276 | NULL); |
277 | if (!rc) { | 277 | if (!rc) { |
@@ -399,7 +399,7 @@ static int ocfs2_read_xattr_block(struct inode *inode, u64 xb_blkno, | |||
399 | int rc; | 399 | int rc; |
400 | struct buffer_head *tmp = *bh; | 400 | struct buffer_head *tmp = *bh; |
401 | 401 | ||
402 | rc = ocfs2_read_block(inode, xb_blkno, &tmp, | 402 | rc = ocfs2_read_block(INODE_CACHE(inode), xb_blkno, &tmp, |
403 | ocfs2_validate_xattr_block); | 403 | ocfs2_validate_xattr_block); |
404 | 404 | ||
405 | /* If ocfs2_read_block() got us a new bh, pass it up. */ | 405 | /* If ocfs2_read_block() got us a new bh, pass it up. */ |
@@ -724,8 +724,8 @@ static int ocfs2_xattr_shrink_size(struct inode *inode, | |||
724 | } | 724 | } |
725 | 725 | ||
726 | block = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); | 726 | block = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); |
727 | ocfs2_remove_xattr_clusters_from_cache(inode, block, | 727 | ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode), |
728 | alloc_size); | 728 | block, alloc_size); |
729 | cpos += alloc_size; | 729 | cpos += alloc_size; |
730 | trunc_len -= alloc_size; | 730 | trunc_len -= alloc_size; |
731 | } | 731 | } |
@@ -970,7 +970,8 @@ static int ocfs2_xattr_get_value_outside(struct inode *inode, | |||
970 | blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); | 970 | blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); |
971 | /* Copy ocfs2_xattr_value */ | 971 | /* Copy ocfs2_xattr_value */ |
972 | for (i = 0; i < num_clusters * bpc; i++, blkno++) { | 972 | for (i = 0; i < num_clusters * bpc; i++, blkno++) { |
973 | ret = ocfs2_read_block(inode, blkno, &bh, NULL); | 973 | ret = ocfs2_read_block(INODE_CACHE(inode), blkno, |
974 | &bh, NULL); | ||
974 | if (ret) { | 975 | if (ret) { |
975 | mlog_errno(ret); | 976 | mlog_errno(ret); |
976 | goto out; | 977 | goto out; |
@@ -1208,7 +1209,8 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode, | |||
1208 | blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); | 1209 | blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); |
1209 | 1210 | ||
1210 | for (i = 0; i < num_clusters * bpc; i++, blkno++) { | 1211 | for (i = 0; i < num_clusters * bpc; i++, blkno++) { |
1211 | ret = ocfs2_read_block(inode, blkno, &bh, NULL); | 1212 | ret = ocfs2_read_block(INODE_CACHE(inode), blkno, |
1213 | &bh, NULL); | ||
1212 | if (ret) { | 1214 | if (ret) { |
1213 | mlog_errno(ret); | 1215 | mlog_errno(ret); |
1214 | goto out; | 1216 | goto out; |
@@ -2121,7 +2123,7 @@ static int ocfs2_xattr_block_set(struct inode *inode, | |||
2121 | } | 2123 | } |
2122 | 2124 | ||
2123 | new_bh = sb_getblk(inode->i_sb, first_blkno); | 2125 | new_bh = sb_getblk(inode->i_sb, first_blkno); |
2124 | ocfs2_set_new_buffer_uptodate(inode, new_bh); | 2126 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh); |
2125 | 2127 | ||
2126 | ret = ocfs2_journal_access_xb(handle, inode, new_bh, | 2128 | ret = ocfs2_journal_access_xb(handle, inode, new_bh, |
2127 | OCFS2_JOURNAL_ACCESS_CREATE); | 2129 | OCFS2_JOURNAL_ACCESS_CREATE); |
@@ -4845,7 +4847,8 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode, | |||
4845 | mlog(0, "rm xattr extent rec at %u len = %u, start from %llu\n", | 4847 | mlog(0, "rm xattr extent rec at %u len = %u, start from %llu\n", |
4846 | cpos, len, (unsigned long long)blkno); | 4848 | cpos, len, (unsigned long long)blkno); |
4847 | 4849 | ||
4848 | ocfs2_remove_xattr_clusters_from_cache(inode, blkno, len); | 4850 | ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode), blkno, |
4851 | len); | ||
4849 | 4852 | ||
4850 | ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); | 4853 | ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); |
4851 | if (ret) { | 4854 | if (ret) { |