* [PATCH] ext4: remove redundant check buffer_uptodate()
@ 2021-04-26 3:23 Joseph Qi
2021-04-26 5:05 ` riteshh
0 siblings, 1 reply; 3+ messages in thread
From: Joseph Qi @ 2021-04-26 3:23 UTC (permalink / raw)
To: tytso, adilger.kernel; +Cc: linux-ext4
Now set_buffer_uptodate() will test first and then set, so we don't have
to check buffer_uptodate() first, remove it to simplify code.
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
---
fs/ext4/inode.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0948a43..9e02538 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1065,10 +1065,8 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
block++, block_start = block_end, bh = bh->b_this_page) {
block_end = block_start + blocksize;
if (block_end <= from || block_start >= to) {
- if (PageUptodate(page)) {
- if (!buffer_uptodate(bh))
- set_buffer_uptodate(bh);
- }
+ if (PageUptodate(page))
+ set_buffer_uptodate(bh);
continue;
}
if (buffer_new(bh))
@@ -1092,8 +1090,7 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
}
}
if (PageUptodate(page)) {
- if (!buffer_uptodate(bh))
- set_buffer_uptodate(bh);
+ set_buffer_uptodate(bh);
continue;
}
if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: remove redundant check buffer_uptodate()
2021-04-26 3:23 [PATCH] ext4: remove redundant check buffer_uptodate() Joseph Qi
@ 2021-04-26 5:05 ` riteshh
2021-04-26 6:15 ` Joseph Qi
0 siblings, 1 reply; 3+ messages in thread
From: riteshh @ 2021-04-26 5:05 UTC (permalink / raw)
To: Joseph Qi; +Cc: tytso, adilger.kernel, linux-ext4
On 21/04/26 11:23AM, Joseph Qi wrote:
> Now set_buffer_uptodate() will test first and then set, so we don't have
> to check buffer_uptodate() first, remove it to simplify code.
Maybe we can change below function as well then.
No need to check same thing twice since set_buffer_uptodate() is already doing
the check.
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b258e8279266..856bd9981409 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3749,7 +3749,7 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
* have to read the block because we may read the old data
* successfully.
*/
- if (!buffer_uptodate(bh) && buffer_write_io_error(bh))
+ if (buffer_write_io_error(bh))
set_buffer_uptodate(bh);
return buffer_uptodate(bh);
}
With that pls feel free to add:
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
>
> Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> ---
> fs/ext4/inode.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 0948a43..9e02538 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1065,10 +1065,8 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
> block++, block_start = block_end, bh = bh->b_this_page) {
> block_end = block_start + blocksize;
> if (block_end <= from || block_start >= to) {
> - if (PageUptodate(page)) {
> - if (!buffer_uptodate(bh))
> - set_buffer_uptodate(bh);
> - }
> + if (PageUptodate(page))
> + set_buffer_uptodate(bh);
> continue;
> }
> if (buffer_new(bh))
> @@ -1092,8 +1090,7 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
> }
> }
> if (PageUptodate(page)) {
> - if (!buffer_uptodate(bh))
> - set_buffer_uptodate(bh);
> + set_buffer_uptodate(bh);
> continue;
> }
> if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
> --
> 1.8.3.1
>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: remove redundant check buffer_uptodate()
2021-04-26 5:05 ` riteshh
@ 2021-04-26 6:15 ` Joseph Qi
0 siblings, 0 replies; 3+ messages in thread
From: Joseph Qi @ 2021-04-26 6:15 UTC (permalink / raw)
To: riteshh, Joseph Qi; +Cc: tytso, adilger.kernel, linux-ext4
On 4/26/21 1:05 PM, riteshh wrote:
> On 21/04/26 11:23AM, Joseph Qi wrote:
>> Now set_buffer_uptodate() will test first and then set, so we don't have
>> to check buffer_uptodate() first, remove it to simplify code.
>
> Maybe we can change below function as well then.
> No need to check same thing twice since set_buffer_uptodate() is already doing
> the check.
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index b258e8279266..856bd9981409 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3749,7 +3749,7 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
> * have to read the block because we may read the old data
> * successfully.
> */
> - if (!buffer_uptodate(bh) && buffer_write_io_error(bh))
> + if (buffer_write_io_error(bh))
> set_buffer_uptodate(bh);
> return buffer_uptodate(bh);
> }
>
> With that pls feel free to add:
> Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
>
Sure, will send v2 with above addressed.
Thanks,
Joseph
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-26 6:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 3:23 [PATCH] ext4: remove redundant check buffer_uptodate() Joseph Qi
2021-04-26 5:05 ` riteshh
2021-04-26 6:15 ` Joseph Qi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.