From patchwork Fri Nov 17 21:15:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13459599 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 DF536C5AD4C for ; Fri, 17 Nov 2023 21:18:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD9078D0061; Fri, 17 Nov 2023 16:18:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BEB598D005B; Fri, 17 Nov 2023 16:18:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A65038D0061; Fri, 17 Nov 2023 16:18:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 926B08D005B for ; Fri, 17 Nov 2023 16:18:40 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6D40880E0B for ; Fri, 17 Nov 2023 21:18:40 +0000 (UTC) X-FDA: 81468710400.18.928E8B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 9F68020021 for ; Fri, 17 Nov 2023 21:18:38 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fyXgkCdG; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700255918; 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=lr+2x0KwBOZEsditfYiGs6AJLLCWZ6zNWlFkfokEznY=; b=vs1G3W6tbUzCW055k3LnFKq64mZjQVLQTa97vyytgWqzGLs9qvpkZdK9hVbhFa0f/qEf27 BFEGBnDP7L9C3SWgc5TE3W/IwP32fhOSHe8oNzrrkkqoztEXiVJ+CLlVk37EaogqLpAd1f vKpcgHBmKWHRGJV2r1jbbu1SiD3a8dM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700255918; a=rsa-sha256; cv=none; b=2n5cK56lXfFmJdDtO5vs7UqW2DLXg2BIZx9yjpDlbpo5W+5wAP6v3gZr12PZ7rz7+RmcFV IJ1juvJwila9MMkSULhHnVTXus6LFQq8jbQGTjjS9BbGcdLFk/Io5IsLT3bngUSA8mTI8c WuPO2Gumeq3t6qG2T6mG20h38Rfn4ko= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fyXgkCdG; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700255917; 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=lr+2x0KwBOZEsditfYiGs6AJLLCWZ6zNWlFkfokEznY=; b=fyXgkCdGJ+RMfgiH/GHL0biotLk+XKvNyrfBMfK9N4OaCD/Hy7rQoyD/wsprkyus+6XZad 0lcWDORa3m9ur892U96uMGxGvdPk9qzYA4+NPNQLUOxdVLSTjYn4R3s0hKnWBt5J536JyJ aOH+jx2mx9XZzWI8KRc3RBBdzNhXays= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-232-Bmb0uyA-OrOZt9QIU7JAOQ-1; Fri, 17 Nov 2023 16:18:33 -0500 X-MC-Unique: Bmb0uyA-OrOZt9QIU7JAOQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E3073C0C486; Fri, 17 Nov 2023 21:18:32 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F169C15881; Fri, 17 Nov 2023 21:18:29 +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-cachefs@redhat.com, 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 Subject: [PATCH v2 42/51] cifs: Share server EOF pos with netfslib Date: Fri, 17 Nov 2023 21:15:34 +0000 Message-ID: <20231117211544.1740466-43-dhowells@redhat.com> In-Reply-To: <20231117211544.1740466-1-dhowells@redhat.com> References: <20231117211544.1740466-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Queue-Id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F5y9 knytI1kn6y+T8+84RQThUKaUEZvMi/fLXGR+M0JvR8UhN2w/PE/mNvrDvVZVd+RQP2wdyWY8glwHOYDQoKegwi+UUBoHyQznscsECk0kSpmaieBl22WxK+Eg4X2rXNl6Dnp8SmfOmfu/TeBYPcP0gyyYJcjW3diTXfagAOOCM4Wm24y3mb55FROtZWVkyIx6eTtzC5MzeWjZz0Q+suejYNjFJzSoxEhsxmo53MiXHoottltcpWa27CCkSxZuw8Kamgb0iKfs0qNakFcweFXtgRyuiMCEeEoUSv7iRcKhgQzHQZhb4zGoP2c/33JJNVWRKsyy3dKLK/r7Pv5UW/eLH1ppIkNsJNXwxz8yGlS77lslcKCAIifCUqlT8u+XZNTv3wpUebSAGvuPhtygGtVtyqVpG6oXENqDgANTAWoPQK7mDp7VH8LZvHmZYBnhmpCX6/SSi 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: List-Subscribe: List-Unsubscribe: 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 ea3a7a668b45..c7d8251c28d5 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 0f74aa12e6b6..94f2411861d0 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1531,7 +1531,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 8c9e33efb9a9..385830b02e0a 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -2118,8 +2118,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 @@ -3245,8 +3245,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 86fbd3f847d6..500c8104786d 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -104,7 +104,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) fattr->cf_mtime = timestamp_truncate(fattr->cf_mtime, inode); mtime = inode_get_mtime(inode); if (timespec64_equal(&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; @@ -193,7 +193,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. @@ -2779,7 +2779,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 ae0acf9c411d..bd978544d857 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3562,7 +3562,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); @@ -3654,8 +3654,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; @@ -3690,9 +3690,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: