From patchwork Fri Oct 13 16:04:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13421185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A648BCDB482 for ; Fri, 13 Oct 2023 16:07:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC01580052; Fri, 13 Oct 2023 12:07:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C411280053; Fri, 13 Oct 2023 12:07:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A470F80052; Fri, 13 Oct 2023 12:07:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8FB2780051 for ; Fri, 13 Oct 2023 12:07:09 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4F7131403D1 for ; Fri, 13 Oct 2023 16:07:09 +0000 (UTC) X-FDA: 81340917378.23.8547F67 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 6803B100034 for ; Fri, 13 Oct 2023 16:07:07 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ou3ZJ3HM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697213227; a=rsa-sha256; cv=none; b=4LIuX1IxeE/niYI/PBp7fYOjdNz5wZgUMwwVAxEQJYOUjNrx3Bmv5d/vANqPYNNquIvbJM ZBXdgm3sQtqIIdTTrKg296ADEpJT+CItSvod2E268170pxUDQISgDk8kGRU289l1YaIcFB dVFcnZoBYFusjqRDFaSFIamXaWASjlg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ou3ZJ3HM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697213227; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TOWBTb7dSiEX2Zo576hGEWbl47hY2TK0ZPUPW+cuiow=; b=fkSMzxcVONZtHCp7WzHvNbVsJ4IDYso548IvntZj43++babk8klv7V1KHvqJtYtTDtl2nu /BVPAG9XwgOITswJ5Mkesx9/Ej+NDTIPSrAH7b6asRf0YEFDKxhI3Gy1psTKOzj5PBcU8/ fnhYgC8LQBVGaTiFqUhxH06FaXU25Lo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697213226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TOWBTb7dSiEX2Zo576hGEWbl47hY2TK0ZPUPW+cuiow=; b=Ou3ZJ3HMoOC8WjJtFmI9HMJ7GMaD/F4gOWDteDnCkZVwNcmS1kpjIgTsAPtTXKC9sfXSx6 5woF3xc0niPv+GriRqLXv5P3xNiHw0LaNwAiGHGbGgD1ymUJQeeYKDFBGLIrnIYs51E9SL RhxP2ydAUjPPHVtgaQo4eGQ6H6UfyL0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-mlred8r2Ooqa8GL90Jlipg-1; Fri, 13 Oct 2023 12:07:03 -0400 X-MC-Unique: mlred8r2Ooqa8GL90Jlipg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C93F288B7AD; Fri, 13 Oct 2023 16:07:01 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB8EB492BD9; Fri, 13 Oct 2023 16:06:58 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula , linux-cachefs@redhat.com Subject: [RFC PATCH 44/53] cifs: Share server EOF pos with netfslib Date: Fri, 13 Oct 2023 17:04:13 +0100 Message-ID: <20231013160423.2218093-45-dhowells@redhat.com> In-Reply-To: <20231013160423.2218093-1-dhowells@redhat.com> References: <20231013160423.2218093-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam06 X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tZaq6IN8jYrxr8AXgicpGJlTQVQC4tcNAW+smlvnfYV6LJ/kBTb4oUhTTrkRsxJgqQDG54wYEKZn1OcbhhzkwXcYlCt3scuQ2HmdrxFYFnKs/skV/Lnmu1D1wJwCXAbSy7/RByShGcHzcq4g9ratlosED5pR2GWsK2+yQz+CfeYmjIdKUjear5IVRpwBbeahij96MBj2hxOvYggPtj2+jB3Kv9jhl/xAu/0w9T17nOEcYYJ8GWKfobxLEcpCKIgdF7dRhjhqckrSMDxsf2MXEI4yihPN0xVMXco0UE3lsQiAnSyCJGpDPCi/q6MF4RaIiQLseIHkUpEeTM6GShLNgEi+65oo1+XpyAnvln7N3nv2/bDauMhcbNVDJWv/qeXZYc3DTDmArDAyiXQcFO5HquadRaFrUlORCxk5IdK5vp1sXYcDFMsHm3BTAkELwE0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use cifsi->netfs_ctx.remote_i_size instead of cifsi->server_eof so that netfslib can refer to it to. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/smb/client/cifsfs.c | 2 +- fs/smb/client/cifsglob.h | 1 - fs/smb/client/file.c | 8 ++++---- fs/smb/client/inode.c | 6 +++--- fs/smb/client/smb2ops.c | 10 +++++----- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index 22869cda1356..85799e9e0f4c 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -395,7 +395,7 @@ cifs_alloc_inode(struct super_block *sb) spin_lock_init(&cifs_inode->writers_lock); cifs_inode->writers = 0; cifs_inode->netfs.inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ - cifs_inode->server_eof = 0; + cifs_inode->netfs.remote_i_size = 0; cifs_inode->uniqueid = 0; cifs_inode->createtime = 0; cifs_inode->epoch = 0; diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 22fa98428845..1943d035b8d3 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1527,7 +1527,6 @@ struct cifsInodeInfo { spinlock_t writers_lock; unsigned int writers; /* Number of writers on this inode */ unsigned long time; /* jiffies of last update of inode */ - u64 server_eof; /* current file size on server -- protected by i_lock */ u64 uniqueid; /* server inode number */ u64 createtime; /* creation time on server */ __u8 lease_key[SMB2_LEASE_KEY_SIZE]; /* lease key for this inode */ diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index b4f16ef62115..0383ce61ac35 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -2117,8 +2117,8 @@ cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset, { loff_t end_of_write = offset + bytes_written; - if (end_of_write > cifsi->server_eof) - cifsi->server_eof = end_of_write; + if (end_of_write > cifsi->netfs.remote_i_size) + netfs_resize_file(&cifsi->netfs, end_of_write); } static ssize_t @@ -3246,8 +3246,8 @@ cifs_uncached_writev_complete(struct work_struct *work) spin_lock(&inode->i_lock); cifs_update_eof(cifsi, wdata->offset, wdata->bytes); - if (cifsi->server_eof > inode->i_size) - i_size_write(inode, cifsi->server_eof); + if (cifsi->netfs.remote_i_size > inode->i_size) + i_size_write(inode, cifsi->netfs.remote_i_size); spin_unlock(&inode->i_lock); complete(&wdata->done); diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index d7c302442c1e..6815b50ec56c 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -102,7 +102,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) /* revalidate if mtime or size have changed */ fattr->cf_mtime = timestamp_truncate(fattr->cf_mtime, inode); if (timespec64_equal(&inode->i_mtime, &fattr->cf_mtime) && - cifs_i->server_eof == fattr->cf_eof) { + cifs_i->netfs.remote_i_size == fattr->cf_eof) { cifs_dbg(FYI, "%s: inode %llu is unchanged\n", __func__, cifs_i->uniqueid); return; @@ -191,7 +191,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr) else clear_bit(CIFS_INO_DELETE_PENDING, &cifs_i->flags); - cifs_i->server_eof = fattr->cf_eof; + cifs_i->netfs.remote_i_size = fattr->cf_eof; /* * Can't safely change the file size here if the client is writing to * it due to potential races. @@ -2776,7 +2776,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, set_size_out: if (rc == 0) { - cifsInode->server_eof = attrs->ia_size; + netfs_resize_file(&cifsInode->netfs, attrs->ia_size); cifs_setsize(inode, attrs->ia_size); /* * i_blocks is not related to (i_size / i_blksize), but instead diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index dc18130db9b3..e7f765673246 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3554,7 +3554,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid, cfile->pid, &eof); if (rc == 0) { - cifsi->server_eof = off + len; + netfs_resize_file(&cifsi->netfs, off + len); cifs_setsize(inode, off + len); cifs_truncate_page(inode->i_mapping, inode->i_size); truncate_setsize(inode, off + len); @@ -3646,8 +3646,8 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon, int rc; unsigned int xid; struct inode *inode = file_inode(file); - struct cifsFileInfo *cfile = file->private_data; struct cifsInodeInfo *cifsi = CIFS_I(inode); + struct cifsFileInfo *cfile = file->private_data; __le64 eof; loff_t old_eof; @@ -3682,9 +3682,9 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon, rc = 0; - cifsi->server_eof = i_size_read(inode) - len; - truncate_setsize(inode, cifsi->server_eof); - fscache_resize_cookie(cifs_inode_cookie(inode), cifsi->server_eof); + netfs_resize_file(&cifsi->netfs, eof); + truncate_setsize(inode, eof); + fscache_resize_cookie(cifs_inode_cookie(inode), eof); out_2: filemap_invalidate_unlock(inode->i_mapping); out: