aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2008-08-18 05:38:47 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 16:57:59 -0400
commitac11c827192272eabb68b8f4cf844066461d9690 (patch)
treecd96822f16199879a203d30a4957f7d191c8659d
parent5a7bc8eb29b8c759df374d97b6189e03d4ea71c5 (diff)
ocfs2: Add helper function in uptodate.c for removing xattr clusters
The old uptodate only handles the issue of removing one buffer_head from ocfs2 inode's buffer cache. With xattr clusters, we may need to remove multiple buffer_head's at a time. Signed-off-by: Tao Ma <tao.ma@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r--fs/ocfs2/uptodate.c32
-rw-r--r--fs/ocfs2/uptodate.h3
2 files changed, 29 insertions, 6 deletions
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c
index 4da8851f2b23..e26459e7d554 100644
--- a/fs/ocfs2/uptodate.c
+++ b/fs/ocfs2/uptodate.c
@@ -511,14 +511,10 @@ static void ocfs2_remove_metadata_tree(struct ocfs2_caching_info *ci,
511 ci->ci_num_cached--; 511 ci->ci_num_cached--;
512} 512}
513 513
514/* Called when we remove a chunk of metadata from an inode. We don't 514static void ocfs2_remove_block_from_cache(struct inode *inode,
515 * bother reverting things to an inlined array in the case of a remove 515 sector_t block)
516 * which moves us back under the limit. */
517void ocfs2_remove_from_cache(struct inode *inode,
518 struct buffer_head *bh)
519{ 516{
520 int index; 517 int index;
521 sector_t block = bh->b_blocknr;
522 struct ocfs2_meta_cache_item *item = NULL; 518 struct ocfs2_meta_cache_item *item = NULL;
523 struct ocfs2_inode_info *oi = OCFS2_I(inode); 519 struct ocfs2_inode_info *oi = OCFS2_I(inode);
524 struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; 520 struct ocfs2_caching_info *ci = &oi->ip_metadata_cache;
@@ -544,6 +540,30 @@ void ocfs2_remove_from_cache(struct inode *inode,
544 kmem_cache_free(ocfs2_uptodate_cachep, item); 540 kmem_cache_free(ocfs2_uptodate_cachep, item);
545} 541}
546 542
543/*
544 * Called when we remove a chunk of metadata from an inode. We don't
545 * bother reverting things to an inlined array in the case of a remove
546 * which moves us back under the limit.
547 */
548void ocfs2_remove_from_cache(struct inode *inode,
549 struct buffer_head *bh)
550{
551 sector_t block = bh->b_blocknr;
552
553 ocfs2_remove_block_from_cache(inode, block);
554}
555
556/* Called when we remove xattr clusters from an inode. */
557void ocfs2_remove_xattr_clusters_from_cache(struct inode *inode,
558 sector_t block,
559 u32 c_len)
560{
561 u64 i, b_len = ocfs2_clusters_to_blocks(inode->i_sb, 1) * c_len;
562
563 for (i = 0; i < b_len; i++, block++)
564 ocfs2_remove_block_from_cache(inode, block);
565}
566
547int __init init_ocfs2_uptodate_cache(void) 567int __init init_ocfs2_uptodate_cache(void)
548{ 568{
549 ocfs2_uptodate_cachep = kmem_cache_create("ocfs2_uptodate", 569 ocfs2_uptodate_cachep = kmem_cache_create("ocfs2_uptodate",
diff --git a/fs/ocfs2/uptodate.h b/fs/ocfs2/uptodate.h
index 2e73206059a8..531b4b3a0c47 100644
--- a/fs/ocfs2/uptodate.h
+++ b/fs/ocfs2/uptodate.h
@@ -40,6 +40,9 @@ void ocfs2_set_new_buffer_uptodate(struct inode *inode,
40 struct buffer_head *bh); 40 struct buffer_head *bh);
41void ocfs2_remove_from_cache(struct inode *inode, 41void ocfs2_remove_from_cache(struct inode *inode,
42 struct buffer_head *bh); 42 struct buffer_head *bh);
43void ocfs2_remove_xattr_clusters_from_cache(struct inode *inode,
44 sector_t block,
45 u32 c_len);
43int ocfs2_buffer_read_ahead(struct inode *inode, 46int ocfs2_buffer_read_ahead(struct inode *inode,
44 struct buffer_head *bh); 47 struct buffer_head *bh);
45 48