[RFC PATCH v2 3/4] ext2: remove buffer heads from quota handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, we read and write to quotafiles by storing blocks of data
in buffer_heads. Replace these buffer heads with the new ext2_buffer
and update the buffer functions accordingly.

Signed-off-by: Catherine Hoang <catherine.hoang@xxxxxxxxxx>
---
 fs/ext2/super.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 4323448bf64b..be6fff36bf23 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1506,7 +1506,7 @@ static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data,
 	int tocopy;
 	size_t toread;
 	struct buffer_head tmp_bh;
-	struct buffer_head *bh;
+	struct ext2_buffer *buf;
 	loff_t i_size = i_size_read(inode);
 
 	if (off > i_size)
@@ -1525,11 +1525,11 @@ static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data,
 		if (!buffer_mapped(&tmp_bh))	/* A hole? */
 			memset(data, 0, tocopy);
 		else {
-			bh = sb_bread(sb, tmp_bh.b_blocknr);
-			if (!bh)
-				return -EIO;
-			memcpy(data, bh->b_data+offset, tocopy);
-			brelse(bh);
+			buf = ext2_read_buffer(sb, tmp_bh.b_blocknr);
+			if (IS_ERR(buf))
+				return PTR_ERR(buf);
+			memcpy(data, buf->b_data+offset, tocopy);
+			ext2_put_buffer(sb, buf);
 		}
 		offset = 0;
 		toread -= tocopy;
@@ -1550,7 +1550,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type,
 	int tocopy;
 	size_t towrite = len;
 	struct buffer_head tmp_bh;
-	struct buffer_head *bh;
+	struct ext2_buffer *buf;
 
 	while (towrite > 0) {
 		tocopy = min_t(size_t, sb->s_blocksize - offset, towrite);
@@ -1561,20 +1561,18 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type,
 		if (err < 0)
 			goto out;
 		if (offset || tocopy != EXT2_BLOCK_SIZE(sb))
-			bh = sb_bread(sb, tmp_bh.b_blocknr);
+			buf = ext2_read_buffer(sb, tmp_bh.b_blocknr);
 		else
-			bh = sb_getblk(sb, tmp_bh.b_blocknr);
-		if (unlikely(!bh)) {
-			err = -EIO;
+			buf = ext2_get_buffer(sb, tmp_bh.b_blocknr);
+		if (unlikely(IS_ERR(buf))) {
+			err = PTR_ERR(buf);
 			goto out;
 		}
-		lock_buffer(bh);
-		memcpy(bh->b_data+offset, data, tocopy);
-		flush_dcache_page(bh->b_page);
-		set_buffer_uptodate(bh);
-		mark_buffer_dirty(bh);
-		unlock_buffer(bh);
-		brelse(bh);
+		ext2_buffer_lock(buf);
+		memcpy(buf->b_data+offset, data, tocopy);
+		ext2_buffer_set_dirty(buf);
+		ext2_buffer_unlock(buf);
+		ext2_put_buffer(sb, buf);
 		offset = 0;
 		towrite -= tocopy;
 		data += tocopy;
-- 
2.43.0





[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux