Re: [PATCH 1/2] ceph: flush small range instead of the whole map for truncate

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

 




On 4/7/22 11:45 PM, Jeff Layton wrote:
On Thu, 2022-04-07 at 22:41 +0800, xiubli@xxxxxxxxxx wrote:
From: Xiubo Li <xiubli@xxxxxxxxxx>

Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx>
---
  fs/ceph/inode.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 45ca4e598ef0..f4059d73edd5 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2275,8 +2275,12 @@ static int fill_fscrypt_truncate(struct inode *inode,
  	     ceph_cap_string(issued));
/* Try to writeback the dirty pagecaches */
-	if (issued & (CEPH_CAP_FILE_BUFFER))
-		filemap_write_and_wait(inode->i_mapping);
+	if (issued & (CEPH_CAP_FILE_BUFFER)) {
+		ret = filemap_write_and_wait_range(inode->i_mapping,
+						   orig_pos, LLONG_MAX);
+		if (ret < 0)
+			goto out;
+	}



Not much point in writing back blocks we're just going to truncate away
anyhow. Maybe this should be writing with this range?

     orig_pos, orig_pos + CEPH_FSCRYPT_BLOCK_SIZE - 1

We need to make sure the last block is not buffered in pagecache, because we will aways sync read that from Rados.

Yeah, this looks much better.

I will fix and test it again.

Thanks


page = __page_cache_alloc(GFP_KERNEL);
  	if (page == NULL) {




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux