2023-06-19 21:19:58

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 0/5] clean up block_commit_write

Changelog:

v1--v2:
1. Re-order patches to avoid breaking compilation.

Bean Huo (5):
fs/buffer: clean up block_commit_write
ext4: No need to check return value of block_commit_write()
fs/ocfs2: No need to check return value of block_commit_write()
udf: No need to check return value of block_commit_write()
fs/buffer.c: convert block_commit_write to return void

fs/buffer.c | 24 +++++++-----------------
fs/ext4/move_extent.c | 7 ++-----
fs/ocfs2/file.c | 7 +------
fs/udf/file.c | 6 +++---
include/linux/buffer_head.h | 2 +-
5 files changed, 14 insertions(+), 32 deletions(-)

--
2.34.1



2023-06-19 21:20:08

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 3/5] fs/ocfs2: No need to check return value of block_commit_write()

From: Bean Huo <[email protected]>

Remove unnecessary check on the return value of block_commit_write(),
because it always returns 0.

Signed-off-by: Bean Huo <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
---
fs/ocfs2/file.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index efb09de4343d..39d8dbb26bb3 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -808,12 +808,7 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,


/* must not update i_size! */
- ret = block_commit_write(page, block_start + 1,
- block_start + 1);
- if (ret < 0)
- mlog_errno(ret);
- else
- ret = 0;
+ block_commit_write(page, block_start + 1, block_start + 1);
}

/*
--
2.34.1


2023-06-19 21:21:09

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 5/5] fs/buffer.c: convert block_commit_write to return void

From: Bean Huo <[email protected]>

block_commit_write() always returns 0, this patch changes it to
return void.

Signed-off-by: Bean Huo <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
---
fs/buffer.c | 11 +++++------
include/linux/buffer_head.h | 2 +-
2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index b88bb7ec38be..fa09cf94f771 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2116,7 +2116,7 @@ int __block_write_begin(struct page *page, loff_t pos, unsigned len,
}
EXPORT_SYMBOL(__block_write_begin);

-int block_commit_write(struct page *page, unsigned int from, unsigned int to)
+void block_commit_write(struct page *page, unsigned int from, unsigned int to)
{
unsigned block_start, block_end;
int partial = 0;
@@ -2151,7 +2151,6 @@ int block_commit_write(struct page *page, unsigned int from, unsigned int to)
*/
if (!partial)
SetPageUptodate(page);
- return 0;
}
EXPORT_SYMBOL(block_commit_write);

@@ -2577,11 +2576,11 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
end = PAGE_SIZE;

ret = __block_write_begin(page, 0, end, get_block);
- if (!ret)
- ret = block_commit_write(page, 0, end);
-
- if (unlikely(ret < 0))
+ if (unlikely(ret))
goto out_unlock;
+
+ block_commit_write(page, 0, end);
+
set_page_dirty(page);
wait_for_stable_page(page);
return 0;
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 1520793c72da..873653d2f1aa 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -284,7 +284,7 @@ int cont_write_begin(struct file *, struct address_space *, loff_t,
unsigned, struct page **, void **,
get_block_t *, loff_t *);
int generic_cont_expand_simple(struct inode *inode, loff_t size);
-int block_commit_write(struct page *page, unsigned from, unsigned to);
+void block_commit_write(struct page *page, unsigned int from, unsigned int to);
int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
get_block_t get_block);
/* Convert errno to return value from ->page_mkwrite() call */
--
2.34.1


2023-06-19 21:21:34

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 4/5] udf: No need to check return value of block_commit_write()

From: Bean Huo <[email protected]>

Remove unnecessary check on the return value of block_commit_write(),
because it always returns 0.

Signed-off-by: Bean Huo <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
---
fs/udf/file.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/udf/file.c b/fs/udf/file.c
index 8238f742377b..b1a062922a24 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -67,13 +67,13 @@ static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf)
else
end = PAGE_SIZE;
err = __block_write_begin(page, 0, end, udf_get_block);
- if (!err)
- err = block_commit_write(page, 0, end);
- if (err < 0) {
+ if (err) {
unlock_page(page);
ret = block_page_mkwrite_return(err);
goto out_unlock;
}
+
+ block_commit_write(page, 0, end);
out_dirty:
set_page_dirty(page);
wait_for_stable_page(page);
--
2.34.1