From: Catherine Hoang <catherine.hoang@oracle.com>
To: linux-ext4@vger.kernel.org
Cc: djwong@kernel.org
Subject: [RFC PATCH v2 3/4] ext2: remove buffer heads from quota handling
Date: Tue, 25 Mar 2025 18:49:27 -0700 [thread overview]
Message-ID: <20250326014928.61507-4-catherine.hoang@oracle.com> (raw)
In-Reply-To: <20250326014928.61507-1-catherine.hoang@oracle.com>
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@oracle.com>
---
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
next prev parent reply other threads:[~2025-03-26 1:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 1:49 [RFC PATCH v2 0/4] remove buffer heads from ext2 Catherine Hoang
2025-03-26 1:49 ` [RFC PATCH v2 1/4] ext2: remove buffer heads from superblock Catherine Hoang
2025-03-28 18:24 ` Darrick J. Wong
2025-03-26 1:49 ` [RFC PATCH v2 2/4] ext2: remove buffer heads from group descriptors Catherine Hoang
2025-03-28 18:29 ` Darrick J. Wong
2025-03-26 1:49 ` Catherine Hoang [this message]
2025-03-26 1:49 ` [RFC PATCH v2 4/4] ext2: remove buffer heads from block bitmaps Catherine Hoang
2025-03-27 10:32 ` [RFC PATCH v2 0/4] remove buffer heads from ext2 Christoph Hellwig
2025-04-04 16:43 ` Darrick J. Wong
2025-04-07 6:25 ` Christoph Hellwig
2025-04-07 16:54 ` Darrick J. Wong
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=20250326014928.61507-4-catherine.hoang@oracle.com \
--to=catherine.hoang@oracle.com \
--cc=djwong@kernel.org \
--cc=linux-ext4@vger.kernel.org \
/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