From patchwork Mon Jul 29 16:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13745290 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 4D214C3DA61 for ; Mon, 29 Jul 2024 16:21:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8A1B6B009F; Mon, 29 Jul 2024 12:21:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D39D06B00A0; Mon, 29 Jul 2024 12:21:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDB126B00A1; Mon, 29 Jul 2024 12:21:13 -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 9F81A6B009F for ; Mon, 29 Jul 2024 12:21:13 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 662391203FE for ; Mon, 29 Jul 2024 16:21:13 +0000 (UTC) X-FDA: 82393304826.11.0FB8E4C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id ACD4D20022 for ; Mon, 29 Jul 2024 16:21:11 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZBB+e0j2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722270068; a=rsa-sha256; cv=none; b=fiy2bRdGXAR3ey8K0Wk/MMsgD5BDOKqWKgCjmzNhhoqG3Ry4v8+Oj4lgOOiu+I0bJ5zQuD zdcITAnRHgNfZAuMsBsMMz3hMmWk5faN/YkfHRX7p88+eg/4pijF3U9asQgSFkTZAwVhh0 k0oUeBg3Hn1gQyYfLqBG4ZDMyMnozb8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZBB+e0j2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1722270068; 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=gsLWP+6oHHQR8BoWVXvRdRgXKHN2l9YwS7BTP0t5yr8=; b=kxsMCOINPmcTA7Rid+gBk+LiQVRKidB79MFgaUpH043CkCrRbYNVoL1j69cfHEDXkNNiML cx0sR+uK1G4s5pMAs1BaJ9GERPuLCrXcoPJmza5m8slHwGnTuyiNi1VtHLmmjDOXizEkx9 uxknDU8CsHJgdtVlb9JzTIWlNoUIY0Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722270071; 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=gsLWP+6oHHQR8BoWVXvRdRgXKHN2l9YwS7BTP0t5yr8=; b=ZBB+e0j2xOltQqm33tGZ8Z+naNhOVZiYiYqhDazW89iXqgo77PNToXi2KTTgXyHKwvZdtC ioVE+zSqxPhLsbf5blZTzWzbZS4X5TggUOo3KlddferPnRx4Rd+CsOdFw12VlaX16KKjHJ V91y5fMPtIeIBEL3+T//T35/MX+aQEk= Received: from mx-prod-mc-05.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-377-Qmgpn1yYMICXSDFDQoCngg-1; Mon, 29 Jul 2024 12:21:05 -0400 X-MC-Unique: Qmgpn1yYMICXSDFDQoCngg-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C6FF219560A2; Mon, 29 Jul 2024 16:21:00 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.216]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5C6101955D42; Mon, 29 Jul 2024 16:20:53 +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 06/24] netfs, cifs: Move CIFS_INO_MODIFIED_ATTR to netfs_inode Date: Mon, 29 Jul 2024 17:19:35 +0100 Message-ID: <20240729162002.3436763-7-dhowells@redhat.com> In-Reply-To: <20240729162002.3436763-1-dhowells@redhat.com> References: <20240729162002.3436763-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspam-User: X-Rspamd-Queue-Id: ACD4D20022 X-Rspamd-Server: rspam01 X-Stat-Signature: ne8qq3njsyqmnymznjgiucpnd9n8d3f9 X-HE-Tag: 1722270071-509214 X-HE-Meta: U2FsdGVkX18tud0PvG7y/eHGfhTU60GF4EoP6aAQnsOduf/yR43VwuFM2J5ZfZMZuuEP8dSXd35BF8yDQH6yEbDDw+uBn5d4kG8Y3wUlHRRQ3ZOcERn1U8UfnTYPhbrcwrm+3ko2Y63fNFvi6zsjFtBhL+FNDm/LKf7oxp26joWImNb+Eohv3MSW6nW2VNAlQzmsu2vbxZjO0EVo/2iIpY5zP6mUb/XS9loYdkA9dckjret2QmiQ3w8jdtht0eZ8Ov5eoi2W8DJgilJqMQ9zvSVFVXFHCEvHkNZTOGGBfi2CN6Y0m2wlYe1FIGjzEXqOkp1GZ/jzq1pvOyX68Lg83k0g4MKg3pdd9e1p/FySRujOpzaW5SuGrupr2voMaqmp6C+cMRcO/nhjyWr7ND06GMIn2o9T2P05Ql2/zb9iA9yRwZsoGUZIIsB1Ip6WO1WMOHn/VD39YGYhIRy3VC/3TKTaS1+O+PX1xoqvzq1+uYFoW7H8y9V1zgNPAlRrvA0pE0wQFr/+B+1GPrIjOusZFEJYxkNuOpoEtht3eysS15lU7Ze3Q9T+N1y+Uw15LMUvdMlg7wiUARZ06NUwpRs0uZawky/72CG7v0YhBlJZU5GKC7lbNL4TQgwFPMOlusTyisnaFfFcEWxIS45MYLP/DslAlhKk3VisxX5qwAVezOuRv4EXvdiikGTfPTcjlb/PBjWxrOTxuLsW9wXeU0xHztTL96d1bXLTAjej5Ee3Z4H3+fq+G3S6hr5XfzS1bF0jzoyN99q2WyPHTwEsxLZO2STaZRI+e9+RZI3H0otWw2Q6uy4ttE2eeG81JODYtIkunSf98ssz2fZA9jiHtAE5gCc/P4IGq9xmm+BnKOdgN+cZvd+rNOIQieDp9r8bnmZD4gnQ0Wi+5nTLbti4PSHsfhZcOvJyirUoqUCPQYtxDHlaEIA/8i/hEGrMclblnCpEgjJ4+LzGJdeQCoW9d/j W6qZg+UP NaP35XZ8G+o50Pik4fo27L7TmbMx96M9eNeakuV1yWPloYQk0veAdNAJahkQ2XbgHqFWGzjCzmCSvPxgYa8/s/RbZhN9eD3ifLu7CfsKbJXUy0fV4kFMvMvSHUnYTFnm9u21Vf8rKTzkHZPlSQ0R8IqPFNdtoUEnO+hvE/wV9k8Cc1XXtLr/4sgfSgb0wKIhoSY4GH6LnMTS+dgf7dTIqovDwRtp4PKcmeFAW5O9S9e+s/sPDQFY6MoHNitT8yxiPQfn8cMAMmqinNJfu+3APjHpYZ3aEfEseU0tdhmPZXYzR/TvryxK91fNetWWZgbEXkdEHWGD/5rzhBKj92PfkC6xPPXMlN08Hb/T9n8yb6DNgfcnb707l85+ttLQD+fG2ign5qdu63IyQ/mL8k/Q72GHgS4DMrBvhaBGlPksgE8KId2lEoLmt6FSxYLXGWs/eQzsTV11WqeZa8Y7XJowhUcrC2FadTdhG70Mxi5rbtlcc1k1gOVoBMcxE1XNFaJdZ9S23L2lRthrStHg= 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 fba5b238455b..7ecae5392a1f 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 8e86fec7dcd2..85e6495dc440 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1573,7 +1573,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 b2405dd4d4d4..fd9f82ff44b8 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -286,12 +286,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); @@ -338,7 +332,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, @@ -1362,7 +1355,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 5d0288938cc2..2d438aaae685 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 */ #define NETFS_ICTX_USE_PGPRIV2 31 /* [DEPRECATED] Use PG_private_2 to mark * write to cache on read */ };