aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/ocfs2.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/ocfs2.h')
-rw-r--r--fs/ocfs2/ocfs2.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index faeb53f2eecf..2699f7cac21a 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -463,6 +463,38 @@ static inline unsigned long ocfs2_align_bytes_to_sectors(u64 bytes)
463 return (unsigned long)((bytes + 511) >> 9); 463 return (unsigned long)((bytes + 511) >> 9);
464} 464}
465 465
466static inline unsigned int ocfs2_page_index_to_clusters(struct super_block *sb,
467 unsigned long pg_index)
468{
469 u32 clusters = pg_index;
470 unsigned int cbits = OCFS2_SB(sb)->s_clustersize_bits;
471
472 if (unlikely(PAGE_CACHE_SHIFT > cbits))
473 clusters = pg_index << (PAGE_CACHE_SHIFT - cbits);
474 else if (PAGE_CACHE_SHIFT < cbits)
475 clusters = pg_index >> (cbits - PAGE_CACHE_SHIFT);
476
477 return clusters;
478}
479
480/*
481 * Find the 1st page index which covers the given clusters.
482 */
483static inline unsigned long ocfs2_align_clusters_to_page_index(struct super_block *sb,
484 u32 clusters)
485{
486 unsigned int cbits = OCFS2_SB(sb)->s_clustersize_bits;
487 unsigned long index = clusters;
488
489 if (PAGE_CACHE_SHIFT > cbits) {
490 index = clusters >> (PAGE_CACHE_SHIFT - cbits);
491 } else if (PAGE_CACHE_SHIFT < cbits) {
492 index = clusters << (cbits - PAGE_CACHE_SHIFT);
493 }
494
495 return index;
496}
497
466#define ocfs2_set_bit ext2_set_bit 498#define ocfs2_set_bit ext2_set_bit
467#define ocfs2_clear_bit ext2_clear_bit 499#define ocfs2_clear_bit ext2_clear_bit
468#define ocfs2_test_bit ext2_test_bit 500#define ocfs2_test_bit ext2_test_bit