Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1421520pxb; Wed, 12 Jan 2022 14:30:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJw17NTHsCzo9un7TQl5tb5pgTh2N1P/wMM0WtwOxBwiJZB3zNfPnqC8twx/HmSX7Zd+FHzA X-Received: by 2002:a17:902:9306:b0:14a:18ab:298c with SMTP id bc6-20020a170902930600b0014a18ab298cmr1832565plb.87.1642026636156; Wed, 12 Jan 2022 14:30:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642026636; cv=none; d=google.com; s=arc-20160816; b=HPBbPzEfAi5nSaq/P4DyaILNCvLqheYked/1VpwLWugZHlqRLN1l9fnDWTED5w4OBi sk8JwPjD0Gf3VveHii8k99h84UlAt9HfcktrOPL6pBiDeg95t+dCSD2RHe1fgxr/W0OW Gms8Nkdv5C7kd6p/a6W+KW+cZ6sBLxKN1Dre0pLtZkZHl3zRHaEkwzU9d2GkIjyJa99C ndsONK/1V2YClcNHRAp+UWvkwZzOQWU5vxc2GKKN1LJEryG6lTJem7CLNn0oYRwjcgRl UKpRcNboRHGgv0HsKMfh3A3QtoBXbP9U2GmZl8BDNorX3dtYwXTSK06zvOknHI5qkgBq /lUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=FtIbmDuJfaFcyPVq4lejO1YQT8JqBoet7CpPdE4P+Vs=; b=WiooEMXZqF4ZDaCum+EEqwSFOOIojrbo2fEHtVAmkveERD2NHkEgg1wsB96kTXrhV9 yljqGc90w87rPNo5M6eFq4pCeJDuIaRGbNMGTnPY+snJbjRIka2QJN/Fp78peDTnQ1/9 Vm+Lk7nX0PvQl/cPiIiNUJN0uhIwgwdfNy0SKUiB1tlbYIsX69LG/MPRLb9Wbyj3uA+K mfvjKleisqd7xx7msHq92SidomChYaXV+ZIOt4xHJOv79ke8s5UZHf8EZgRgwbHiL87R bWOlZo0RFeln04Jx5JziSs3Zyl5q/m7XSGTRVnOAEqRMRqacWNtlJFxAIAETlWJaBgwz 7yUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fjJ0xsyn; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si1122470plx.120.2022.01.12.14.30.23; Wed, 12 Jan 2022 14:30:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fjJ0xsyn; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351185AbiALHU6 (ORCPT + 99 others); Wed, 12 Jan 2022 02:20:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28533 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351175AbiALHU4 (ORCPT ); Wed, 12 Jan 2022 02:20:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641972056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FtIbmDuJfaFcyPVq4lejO1YQT8JqBoet7CpPdE4P+Vs=; b=fjJ0xsynsk5eXCw2cnqb8kVizQjnUDAV065WDY03JJT3dKjjEBhBK5dpo793WAcHV4T3Hv nc/HWOlQwjD4fDC4obVRDTfbB2G3k/Q67GJcf5l8+Q09mw+3/g36BMiEq3GgqUNNY77Adl hNBjME4kZn8cm2ziSnBq2eOf2tX1R3k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-iG6Fe2TPNT6yCUhnGs8TxA-1; Wed, 12 Jan 2022 02:20:50 -0500 X-MC-Unique: iG6Fe2TPNT6yCUhnGs8TxA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 158141023F50; Wed, 12 Jan 2022 07:20:48 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 914407B9D2; Wed, 12 Jan 2022 07:20:41 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <3462849.1641593783@warthog.procyon.org.uk> References: <3462849.1641593783@warthog.procyon.org.uk> <164021579335.640689.2681324337038770579.stgit@warthog.procyon.org.uk> <164021479106.640689.17404516570194656552.stgit@warthog.procyon.org.uk> To: Steve French Cc: dhowells@redhat.com, linux-cachefs@redhat.com, Shyam Prasad N , linux-cifs@vger.kernel.org, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , JeffleXu , Linus Torvalds , linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 63/68] cifs: Support fscache indexing rewrite MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <534839.1641972040.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 12 Jan 2022 07:20:40 +0000 Message-ID: <534840.1641972040@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Hi Steve, I think this needs the further changes below, which I will fold in. The issues are: (1) One of the error paths in cifs_atomic_open() uses the cookie when it should jump around that. (2) There's an additional successful return from the middle of cifs_open(= ) that I mistook for an error path, but does need to use the cookie on the way out. David --- diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 6186824b366e..bf3b4c9901b9 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -508,6 +508,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *d= irentry, server->ops->close(xid, tcon, &fid); cifs_del_pending_open(&open); rc =3D -ENOMEM; + goto out; } = fscache_use_cookie(cifs_inode_cookie(file_inode(file)), diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 44da7646f789..47333730c963 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -568,7 +568,7 @@ int cifs_open(struct inode *inode, struct file *file) spin_lock(&CIFS_I(inode)->deferred_lock); cifs_del_deferred_close(cfile); spin_unlock(&CIFS_I(inode)->deferred_lock); - goto out; + goto use_cache; } else { _cifsFileInfo_put(cfile, true, false); } @@ -630,19 +630,6 @@ int cifs_open(struct inode *inode, struct file *file) goto out; } = - - fscache_use_cookie(cifs_inode_cookie(file_inode(file)), - file->f_mode & FMODE_WRITE); - if (file->f_flags & O_DIRECT && - (!((file->f_flags & O_ACCMODE) !=3D O_RDONLY) || - file->f_flags & O_APPEND)) { - struct cifs_fscache_inode_coherency_data cd; - cifs_fscache_fill_coherency(file_inode(file), &cd); - fscache_invalidate(cifs_inode_cookie(file_inode(file)), - &cd, i_size_read(file_inode(file)), - FSCACHE_INVAL_DIO_WRITE); - } - if ((oplock & CIFS_CREATE_ACTION) && !posix_open_ok && tcon->unix_ext) { /* * Time to set mode which we can not set earlier due to @@ -661,6 +648,19 @@ int cifs_open(struct inode *inode, struct file *file) cfile->pid); } = +use_cache: + fscache_use_cookie(cifs_inode_cookie(file_inode(file)), + file->f_mode & FMODE_WRITE); + if (file->f_flags & O_DIRECT && + (!((file->f_flags & O_ACCMODE) !=3D O_RDONLY) || + file->f_flags & O_APPEND)) { + struct cifs_fscache_inode_coherency_data cd; + cifs_fscache_fill_coherency(file_inode(file), &cd); + fscache_invalidate(cifs_inode_cookie(file_inode(file)), + &cd, i_size_read(file_inode(file)), + FSCACHE_INVAL_DIO_WRITE); + } + out: free_dentry_path(page); free_xid(xid);