From patchwork Wed Aug 14 20:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13763954 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 5F447C3DA4A for ; Wed, 14 Aug 2024 20:40:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7ACC6B009B; Wed, 14 Aug 2024 16:39:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E28EF6B009C; Wed, 14 Aug 2024 16:39:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF9D06B009D; Wed, 14 Aug 2024 16:39:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B14B46B009B for ; Wed, 14 Aug 2024 16:39:59 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 770A34123F for ; Wed, 14 Aug 2024 20:39:59 +0000 (UTC) X-FDA: 82452017718.16.3B0CFBC 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 C317D100008 for ; Wed, 14 Aug 2024 20:39:57 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=a4Qf5SUm; spf=pass (imf14.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=1723667985; 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=Xvg09nAt+yf4NVEcyGTKLEn8Q0Nrtw1zYvLWuxTLRzA=; b=wl5Q/rARQQhlps+oJL2FazahWTPr2DN/+NJxzQgRAnLJWTLLvEZgwT1jFouQ5ezr3m/8Kg IpEypl2fz/FnpKr+k8ZtF46rzn0F/qjGN7+HhAuTRj+23VkYCjHTG0baYzQtY44UFs+/MJ 6lvmiRmbCG7qLNmdUFoO52IUthRy2/0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=a4Qf5SUm; spf=pass (imf14.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723667985; a=rsa-sha256; cv=none; b=k9N6s8Uix1JXV2UCqFZDv26150GmYBZS18SVufTWJodIwEErysjev2nLuEkHsICYJLXW5a Db+yQbOgU9ur2h7pm7OfpI3v2InoNjHk27bs8tBELH6crVoqEK8h5ZsGdf3EsBkjNWNGUk 1i6CzojiYUGKgoiyIEcGwXkSUuUhcqQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723667997; 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=Xvg09nAt+yf4NVEcyGTKLEn8Q0Nrtw1zYvLWuxTLRzA=; b=a4Qf5SUmFv/CzqcNcEJbGt62BVyBYYVuCx6S+5ZUeWIP6pDWYHO3zEjsIKbNmqrEN5JCVp 9BDSfUTfVHozM7A2icGj4GweTGqjR3v6XOzzP4CSlJT9Oa3U9v6XdmCuUlhGNmXYz0aF76 rP8Fr4y0LEjZv7edvlqh9UsjvL1sd30= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-3rHT-gkeNMqsiQLJWGWckw-1; Wed, 14 Aug 2024 16:39:52 -0400 X-MC-Unique: 3rHT-gkeNMqsiQLJWGWckw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E154819373D7; Wed, 14 Aug 2024 20:39:49 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1245C1955F6B; Wed, 14 Aug 2024 20:39:43 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, 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-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French Subject: [PATCH v2 06/25] netfs, cifs: Move CIFS_INO_MODIFIED_ATTR to netfs_inode Date: Wed, 14 Aug 2024 21:38:26 +0100 Message-ID: <20240814203850.2240469-7-dhowells@redhat.com> In-Reply-To: <20240814203850.2240469-1-dhowells@redhat.com> References: <20240814203850.2240469-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Stat-Signature: fx9ikqoixktzo6owkshk7mhtctae3nhi X-Rspamd-Queue-Id: C317D100008 X-Rspamd-Server: rspam11 X-HE-Tag: 1723667997-397586 X-HE-Meta: U2FsdGVkX1+oyIh3UW26vLHnhv0Il0OmtLgVeT0ED1SeQ2oXOIR6uCkKbkHhctTrXPXNbsTVjCYelT1KnRUDUr9ElSs37XLrCyNgx6+E0DuUvaTTEWg2b/7YPomQMRRzXsCEvKcsgpiNTx6uw9IzP8fWObPtAgN4WE608eIsdShFkriUsn9YrQU3Sj94V3WJ8Gc43VYD3v/bMqg7Mxuohng0hjgzd1TyCQoprsSx+bZkO+4alfrzhztC3MO9uyHceCF971vgZoQV/7AuYzxsTgLqJC8KvJKU08LRPBlXnbbcaxgfCIQADMdpNCVA7Yu8RwqzMflTeZ/73pBfatKtF48mhjJmWOte6ji3N6YrIopSxe3iR0XT1v87CyVPRKV3PQujm6AeUOKF2+IV+fZd1tVupDVPzLxKD3qhhGA0azsEGyY6B7aK/vG5jDtBHMTIAFrMVEr1fDK+2KerhF7Fq67HIJCHl+gaLXhD+NRdKFjCt7CJvQFmA/2Yy0CXT0KK2PFc2JvddFynmNkYCBGcwU9iviUMQHZOFNhCL+Xo5m5pbmq9y1Rl3xY1hlqWHSU7kjwY+38nutgQgHZJfUL40wiSEnP/bBvBwJlETupOBiboFNAc4dWJbTKJLGM89LuxzHD2nS2OnzjA9XfZpnBfhVe/C6B/23eFg1Hu2gXcb5pHLW9LGgp3TFFtc2jYvLDnI/3O7atg9kyK8dB6sXSIdXII6aRlmkkNYb0d6WbcC0DfMmAVWjvbSFZrKjZJTKlZnzj05UCiID/q1uJq1n9035naInsaQUsFgwUuXyZlpmtJi+pSdN9SF1MgkRQgvw9xvOtmfvDvMGREKf10J8qfbv+oioyL9kol9tyNrQxkwpOlCbxRdMDwX27umL1xl5Nsjj8yyae1k5/MXghOXfjnBSuj6PQMc8Y1JoxfSJXtYPf+V1aLXb1Ad6HYeDpfi4MKXqVcgK+q9V0DZB/7qAH 8Ynwi+UQ +iMuE4PCx+d8mev8LT5/AG0lCLiqA0Evuv2IxAL4MMWMxLm8rrR6/CMCVnuLgDerysZ9kToc8zYwhFfi6Ey7poCbzv1Q4A5HTe8aGa4oHMoUNge2ZQ5liezXYM++jFyQGBrr7BIcdK+IgRKMvMBARGBM6XjRl0z+RYZfkPHl7XU86Ebhnr0vzKvs1QGfyQWCJB/Zo9+q5xZMcovQ3WwX3SLO9LWDiuscQi9ZROfNnbkkOmzxt0Ub0dPgpW6GKrFsAj1NSe6ivSATmQ6maubm/FGKgJwzKKEoyRyrqB/PyV4Y2hsyc8RssDyY2ySF+46m1ANiuUyx9QKbpPPUhs5LG4ZACRCWOGfmi6MhUDHWrwg4H/Cg9Up6UgEMMo2Js9bfyUc0hQeRRbcIDm1hcy/oS5ICqhrkEGwOXFrL32cGLt47MOTkbxYahvSkcDcBG5nnWggp4kwvwO6DWaLpAKbVYssKJI4RJC1K0MS+mOIlgXH1cbJdPFs+eM9ZuMaezWUbrSCzmN8lGKj4rO/o= 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: Move CIFS_INO_MODIFIED_ATTR to netfs_inode as NETFS_ICTX_MODIFIED_ATTR and then make netfs_perform_write() set it. This means that cifs doesn't need to implement the ->post_modify() hook. Signed-off-by: David Howells cc: Jeff Layton cc: Steve French cc: Paulo Alcantara cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/buffered_write.c | 10 ++++++++-- fs/smb/client/cifsglob.h | 1 - fs/smb/client/file.c | 9 +-------- include/linux/netfs.h | 1 + 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 327e5904b090..d7eae597e54d 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -372,8 +372,14 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, } while (iov_iter_count(iter)); out: - if (likely(written) && ctx->ops->post_modify) - ctx->ops->post_modify(inode); + if (likely(written)) { + /* Set indication that ctime and mtime got updated in case + * close is deferred. + */ + set_bit(NETFS_ICTX_MODIFIED_ATTR, &ctx->flags); + if (unlikely(ctx->ops->post_modify)) + ctx->ops->post_modify(inode); + } if (unlikely(wreq)) { ret2 = netfs_end_writethrough(wreq, &wbc, writethrough); diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 5c9b3e6cd95f..1028881098e1 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1550,7 +1550,6 @@ struct cifsInodeInfo { #define CIFS_INO_DELETE_PENDING (3) /* delete pending on server */ #define CIFS_INO_INVALID_MAPPING (4) /* pagecache is invalid */ #define CIFS_INO_LOCK (5) /* lock bit for synchronization */ -#define CIFS_INO_MODIFIED_ATTR (6) /* Indicate change in mtime/ctime */ #define CIFS_INO_CLOSE_ON_LOCK (7) /* Not to defer the close when lock is set */ unsigned long flags; spinlock_t writers_lock; diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 3f3842e7b44a..419bfd0c0cbb 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -287,12 +287,6 @@ static void cifs_rreq_done(struct netfs_io_request *rreq) inode_set_atime_to_ts(inode, inode_get_mtime(inode)); } -static void cifs_post_modify(struct inode *inode) -{ - /* Indication to update ctime and mtime as close is deferred */ - set_bit(CIFS_INO_MODIFIED_ATTR, &CIFS_I(inode)->flags); -} - static void cifs_free_request(struct netfs_io_request *rreq) { struct cifs_io_request *req = container_of(rreq, struct cifs_io_request, rreq); @@ -339,7 +333,6 @@ const struct netfs_request_ops cifs_req_ops = { .clamp_length = cifs_clamp_length, .issue_read = cifs_req_issue_read, .done = cifs_rreq_done, - .post_modify = cifs_post_modify, .begin_writeback = cifs_begin_writeback, .prepare_write = cifs_prepare_write, .issue_write = cifs_issue_write, @@ -1363,7 +1356,7 @@ int cifs_close(struct inode *inode, struct file *file) dclose = kmalloc(sizeof(struct cifs_deferred_close), GFP_KERNEL); if ((cfile->status_file_deleted == false) && (smb2_can_defer_close(inode, dclose))) { - if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) { + if (test_and_clear_bit(NETFS_ICTX_MODIFIED_ATTR, &cinode->netfs.flags)) { inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); } diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 983816608f15..574df0402c44 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -73,6 +73,7 @@ struct netfs_inode { #define NETFS_ICTX_ODIRECT 0 /* The file has DIO in progress */ #define NETFS_ICTX_UNBUFFERED 1 /* I/O should not use the pagecache */ #define NETFS_ICTX_WRITETHROUGH 2 /* Write-through caching */ +#define NETFS_ICTX_MODIFIED_ATTR 3 /* Indicate change in mtime/ctime */ }; /*