linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jose R. Santos" <jrs@us.ibm.com>
To: "Jose R. Santos" <jrs@us.ibm.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	linux-ext4@vger.kernel.org
Subject: [RFC PATCH 7/9][e2fsprogs] Add new blk64_t handling inline functions
Date: Fri, 09 May 2008 11:40:12 -0500	[thread overview]
Message-ID: <20080509164012.15484.60952.stgit@gara> (raw)
In-Reply-To: <20080509163928.15484.22146.stgit@gara>

From: Jose R. Santos <jrs@us.ibm.com>

Add new blk64_t handling inline functions

Introduce inline fuctions to handle blk64_t and low/high values in
super blocks and inodes.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
--

 lib/ext2fs/ext2fs.h |   91 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 84 insertions(+), 7 deletions(-)

diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index f578c19..ed99901 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -1135,10 +1135,21 @@ extern void ext2fs_mark_ib_dirty(ext2_filsys fs);
 extern void ext2fs_mark_bb_dirty(ext2_filsys fs);
 extern int ext2fs_test_ib_dirty(ext2_filsys fs);
 extern int ext2fs_test_bb_dirty(ext2_filsys fs);
+extern int ext2fs_group_of_blk2(ext2_filsys fs, blk64_t);
 extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
 extern int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino);
+extern blk64_t ext2fs_blocks_count(ext2_filsys fs);
+extern void ext2_blocks_count_set(ext2_filsys fs, blk64_t blk);
+extern blk64_t ext2_r_blocks_count(ext2_filsys fs);
+extern void ext2_r_blocks_count_set(ext2_filsys fs, blk64_t blk);
+extern blk64_t ext2_free_blocks_count(ext2_filsys fs);
+extern void ext2_free_blocks_count_set(ext2_filsys fs, blk64_t blk);
+extern blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group);
 extern blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group);
+extern blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group);
 extern blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group);
+extern blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs,
+					  struct ext2_inode *inode);
 extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
 				      struct ext2_inode *inode);
 extern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b);
@@ -1299,12 +1310,17 @@ _INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs)
 /*
  * Return the group # of a block
  */
-_INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
+_INLINE_ int ext2fs_group_of_blk2(ext2_filsys fs, blk64_t blk)
 {
 	return (blk - fs->super->s_first_data_block) /
 		fs->super->s_blocks_per_group;
 }
 
+_INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
+{
+	return ext2fs_group_of_blk2(fs, blk);
+}
+
 /*
  * Return the group # of an inode number
  */
@@ -1313,31 +1329,91 @@ _INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino)
 	return (ino - 1) / fs->super->s_inodes_per_group;
 }
 
+_INLINE_ blk64_t ext2fs_blocks_count(ext2_filsys fs)
+{
+	return fs->super->s_blocks_count |
+		(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
+		(__u64) fs->super->s_blocks_count_hi << 32 : 0);
+}
+
+_INLINE_ void ext2_blocks_count_set(ext2_filsys fs, blk64_t blk)
+{
+	fs->super->s_blocks_count = blk;
+	if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
+		fs->super->s_blocks_count_hi = (__u64) blk >> 32;
+}
+
+_INLINE_ blk64_t ext2_r_blocks_count(ext2_filsys fs)
+{
+	return fs->super->s_r_blocks_count |
+		(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
+		(__u64) fs->super->s_r_blocks_count_hi << 32 : 0);
+}
+
+_INLINE_ void ext2_r_blocks_count_set(ext2_filsys fs, blk64_t blk)
+{
+	fs->super->s_r_blocks_count = blk;
+	if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
+		fs->super->s_r_blocks_count_hi = (__u64) blk >> 32;
+}
+
+_INLINE_ blk64_t ext2_free_blocks_count(ext2_filsys fs)
+{
+	return fs->super->s_free_blocks_count |
+		(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
+		(__u64) fs->super->s_free_blocks_hi << 32 : 0);
+}
+
+_INLINE_ void ext2_free_blocks_count_set(ext2_filsys fs, blk64_t blk)
+{
+	fs->super->s_free_blocks_count = blk;
+	if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
+		fs->super->s_free_blocks_hi = (__u64) blk >> 32;
+}
+
 /*
  * Return the first block (inclusive) in a group
  */
-_INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
+_INLINE_ blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group)
 {
 	return fs->super->s_first_data_block +
 		(group * fs->super->s_blocks_per_group);
 }
 
+_INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
+{
+	return ext2fs_group_first_block2(fs, group);
+}
+
 /*
  * Return the last block (inclusive) in a group
  */
-_INLINE_ blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group)
+_INLINE_ blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group)
 {
 	return (group == fs->group_desc_count - 1 ?
-		fs->super->s_blocks_count - 1 :
-		ext2fs_group_first_block(fs, group) +
+		ext2fs_blocks_count(fs) - 1 :
+		ext2fs_group_first_block2(fs, group) +
 			(fs->super->s_blocks_per_group - 1));
 }
 
+_INLINE_ blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group)
+{
+	return ext2fs_group_last_block2(fs, group);
+}
+
+_INLINE_ blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs,
+					struct ext2_inode *inode)
+{
+	return (inode->i_blocks |
+		(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
+		(__u64)inode->osd2.linux2.l_i_blocks_hi << 32 : 0)) -
+		(inode->i_file_acl ? fs->blocksize >> 9 : 0);
+}
+
 _INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
 					struct ext2_inode *inode)
 {
-       return inode->i_blocks -
-              (inode->i_file_acl ? fs->blocksize >> 9 : 0);
+	return ext2fs_inode_data_blocks2(fs, inode);
 }
 
 /*
@@ -1349,6 +1425,7 @@ _INLINE_ unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b)
 		return 0;
 	return ((a - 1) / b) + 1;
 }
+
 #undef _INLINE_
 #endif
 


  parent reply	other threads:[~2008-05-09 16:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-09 16:39 [RFC PATCH 0/9][e2fsprogs] Initial blk64_t capable API calls Jose R. Santos
2008-05-09 16:39 ` [RFC PATCH 1/9][e2fsprogs] Add ext2_off64_t type Jose R. Santos
2008-05-09 16:39 ` [RFC PATCH 2/9][e2fsprogs] Use blk64_t for blocks in struct ext2_file Jose R. Santos
2008-05-09 16:39 ` [RFC PATCH 3/9][e2fsprogs] Add 64-bit dirblock interface Jose R. Santos
2008-05-09 16:39 ` [RFC PATCH 4/9][e2fsprogs] Add 64-bit alloc_stats interface Jose R. Santos
2008-05-12 14:43   ` Theodore Tso
2008-05-12 17:25     ` Jose R. Santos
2008-05-09 16:39 ` [RFC PATCH 5/9][e2fsprogs] Add 64-bit alloc interface Jose R. Santos
2008-05-09 16:40 ` [RFC PATCH 6/9][e2fsprogs] Add 64-bit ext_attr interface Jose R. Santos
2008-05-12 14:47   ` Theodore Tso
2008-05-09 16:40 ` Jose R. Santos [this message]
2008-05-12 14:49   ` [RFC PATCH 7/9][e2fsprogs] Add new blk64_t handling inline functions Theodore Tso
2008-05-12 17:25     ` Jose R. Santos
2008-05-12 19:22       ` Theodore Tso
2008-05-09 16:40 ` [RFC PATCH 8/9][e2fsprogs] Add 64-bit closefs interface Jose R. Santos
2008-05-12 15:05   ` Theodore Tso
2008-05-12 17:24     ` Jose R. Santos
2008-05-12 19:29       ` Theodore Tso
2008-05-09 16:40 ` [RFC PATCH 9/9][e2fsprogs] Add 64-bit openfs interface Jose R. Santos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080509164012.15484.60952.stgit@gara \
    --to=jrs@us.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).