All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve French <smfrench@gmail.com>
To: CIFS <linux-cifs@vger.kernel.org>
Cc: Shyam Prasad N <nspmangalore@gmail.com>,
	Meetakshi Setiya <meetakshisetiyaoss@gmail.com>,
	 Bharath S M <bharathsm@microsoft.com>,
	Paulo Alcantara <pc@manguebit.com>
Subject: [PATCH][SMB3 client] update allocation size more accurately on write completion
Date: Thu, 22 Feb 2024 00:40:31 -0600	[thread overview]
Message-ID: <CAH2r5mtsvNU--3EDFvAPSVuSnLpmbDr5A4YbaY=9rrndLyOpiA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Changes to allocation size are approximated for extending writes of
cached files until the server returns the actual value (on SMB3 close
or query info for example), but it was setting the estimated value for
number of blocks to larger than the file size even if the file is
likely sparse which breaks various xfstests (e.g. generic/129, 130,
221, 228).

When i_size and i_blocks are updated in write completion do not
increase allocation size more than what was written (rounded up to 512
bytes).

See attached.

This fixes the recent regression in various xfstests caused by the
xfstest change

commit b4396efc75aba5325f22690303857af4f63d128e
Author: Alexander Patrakov <patrakov@gmail.com>
Date:   Tue Dec 19 04:57:20 2023 +0800

    _require_sparse_files: rewrite as a direct test instead of a black list


-- 
Thanks,

Steve

[-- Attachment #2: 0001-smb3-update-allocation-size-more-accurately-on-write.patch --]
[-- Type: text/x-patch, Size: 1642 bytes --]

From ae33f1b691cc9fd6fc0dfe84981e5e8d5f0cd3d2 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Thu, 22 Feb 2024 00:26:52 -0600
Subject: [PATCH] smb3: update allocation size more accurately on write
 completion

Changes to allocation size are approximated for extending writes of cached
files until the server returns the actual value (on SMB3 close or query info
for example), but it was setting the estimated value for number of blocks
to larger than the file size even if the file is likely sparse which
breaks various xfstests (e.g. generic/129, 130, 221, 228).

When i_size and i_blocks are updated in write completion do not increase
allocation size more than what was written (rounded up to 512 bytes).

Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/smb/client/file.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 05e915162f05..6b2da368d52d 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -3095,8 +3095,15 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
 	if (rc > 0) {
 		spin_lock(&inode->i_lock);
 		if (pos > inode->i_size) {
+			loff_t additional_blocks = (512 - 1 + copied) >> 9;
+
 			i_size_write(inode, pos);
-			inode->i_blocks = (512 - 1 + pos) >> 9;
+			/*
+			 * Estimate new allocation size based on the amount written.
+			 * This will be updated from server on close (and on queryinfo)
+			 */
+			inode->i_blocks = min_t(blkcnt_t, (512 - 1 + pos) >> 9,
+						inode->i_blocks + additional_blocks);
 		}
 		spin_unlock(&inode->i_lock);
 	}
-- 
2.40.1


             reply	other threads:[~2024-02-22  6:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22  6:40 Steve French [this message]
2024-02-23 13:00 ` [PATCH][SMB3 client] update allocation size more accurately on write completion Shyam Prasad N
2024-02-23 13:41   ` Steve French

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='CAH2r5mtsvNU--3EDFvAPSVuSnLpmbDr5A4YbaY=9rrndLyOpiA@mail.gmail.com' \
    --to=smfrench@gmail.com \
    --cc=bharathsm@microsoft.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=meetakshisetiyaoss@gmail.com \
    --cc=nspmangalore@gmail.com \
    --cc=pc@manguebit.com \
    /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 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.