Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3027189rwb; Mon, 15 Aug 2022 16:25:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR6VCyaPzuGrNCwzZRgQvcjkBlQhjtQtD37GX6ZdDIqB0XmSpJmCc+Uzkpece2jXZfjkSSx2 X-Received: by 2002:a17:906:8a4e:b0:730:9fcd:d988 with SMTP id gx14-20020a1709068a4e00b007309fcdd988mr11919690ejc.636.1660605929895; Mon, 15 Aug 2022 16:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605929; cv=none; d=google.com; s=arc-20160816; b=GMWUkpVjj3t6jcFvPTu9WQEUddumymdB8JBgu7RXGJD44B+kln+mM2ZtRvXxzHCBMh vdMOcFyLG2Xum0H1WnxJ24AxPESXiqIDVO7G601fvsB07PIulDuci2ibJQ85mpqRCzDT m2bRPr23pa8ZtktXpMQzPIncCOQlPodEKjz2KdTIc26rpW7RHOGgJRQOCEv1oNN6NVn4 rs/MDSwNldy0aNwmOowIBbPMRVtXB9C4iyPkFVj/2Kshh/nuABaivcv8FncfpvmPDzOV mehjzdXNZfM0z2SocLYqiz/92gcUovC+GF+adtmh20QdMUKGGvg9SrObceNpU/sIbKGq iulg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mLzJpne3tE1vhdCjUqHoY7YE+O4gDq61HNzRI3Tem+0=; b=gwc6Nwkx2Xw3mHg7ZhJbgHe/W9YJ9dXSDcFfN3OUtHP3Lu3PN93QJi/Q9rbAw2Nh9G glpP8Ul2SMt8hY2ww2xBmbCu8h3G0JPDtww2O8tt8XjW+uPvvjZVHy6xvTztg8ZX+/wg sAqccLf/UErZqJ+W0zLz0XUBDaF6uPsbl05DVwLSJ2hkWePmMMMnPhi9QMnhaboyYsFQ 8bkdpmsDT4DvTlDZLEzP/3tLrTQwpDV7lVYQiyt7zqQUk9INaNgEYNFIpGKe5V52U/k4 3BZR14+m2TCfbdQHQ0qTAOYAObqzQGyD7GnxRjzlyZIqOOtQgK6P+OF99RYQFjnkDAfd sGRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z+xYKqGB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp36-20020a1709073e2400b00722e3682c3bsi9567874ejc.257.2022.08.15.16.25.04; Mon, 15 Aug 2022 16:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z+xYKqGB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349658AbiHOVpy (ORCPT + 99 others); Mon, 15 Aug 2022 17:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349726AbiHOVlr (ORCPT ); Mon, 15 Aug 2022 17:41:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DD55C97C; Mon, 15 Aug 2022 12:29:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 379B560EF0; Mon, 15 Aug 2022 19:29:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 429C8C433D7; Mon, 15 Aug 2022 19:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591768; bh=uHGQOZ8Jt+Uw4YGxwDSoD+KHX62l14xtDPFuerpoiho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z+xYKqGBv7Lw0R35+nLWFOCuZX/XEWNEnWqeBZtjm1/VdbZ4IhQRP8jwRKgc5jx7z c1j1DMlagOeMOs+RgaMnzu/Aog87np2AOKJfFd6wbQ024zr0blZzIdvswkuk9c/qQZ 0aCbDoL8StcSWJJQJxUSNvjoLqFLIFuJq9pWWHcM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olga Kornieskaia , Jeff Layton , Chuck Lever Subject: [PATCH 5.19 0006/1157] nfsd: eliminate the NFSD_FILE_BREAK_* flags Date: Mon, 15 Aug 2022 19:49:22 +0200 Message-Id: <20220815180439.734698710@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeff Layton commit 23ba98de6dcec665e15c0ca19244379bb0d30932 upstream. We had a report from the spring Bake-a-thon of data corruption in some nfstest_interop tests. Looking at the traces showed the NFS server allowing a v3 WRITE to proceed while a read delegation was still outstanding. Currently, we only set NFSD_FILE_BREAK_* flags if NFSD_MAY_NOT_BREAK_LEASE was set when we call nfsd_file_alloc. NFSD_MAY_NOT_BREAK_LEASE was intended to be set when finding files for COMMIT ops, where we need a writeable filehandle but don't need to break read leases. It doesn't make any sense to consult that flag when allocating a file since the file may be used on subsequent calls where we do want to break the lease (and the usage of it here seems to be reverse from what it should be anyway). Also, after calling nfsd_open_break_lease, we don't want to clear the BREAK_* bits. A lease could end up being set on it later (more than once) and we need to be able to break those leases as well. This means that the NFSD_FILE_BREAK_* flags now just mirror NFSD_MAY_{READ,WRITE} flags, so there's no need for them at all. Just drop those flags and unconditionally call nfsd_open_break_lease every time. Reported-by: Olga Kornieskaia Link: https://bugzilla.redhat.com/show_bug.cgi?id=2107360 Fixes: 65294c1f2c5e (nfsd: add a new struct file caching facility to nfsd) Cc: # 5.4.x : bb283ca18d1e NFSD: Clean up the show_nf_flags() macro Cc: # 5.4.x Signed-off-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/filecache.c | 22 +--------------------- fs/nfsd/filecache.h | 4 +--- fs/nfsd/trace.h | 2 -- 3 files changed, 2 insertions(+), 26 deletions(-) --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -184,12 +184,6 @@ nfsd_file_alloc(struct inode *inode, uns nf->nf_hashval = hashval; refcount_set(&nf->nf_ref, 1); nf->nf_may = may & NFSD_FILE_MAY_MASK; - if (may & NFSD_MAY_NOT_BREAK_LEASE) { - if (may & NFSD_MAY_WRITE) - __set_bit(NFSD_FILE_BREAK_WRITE, &nf->nf_flags); - if (may & NFSD_MAY_READ) - __set_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags); - } nf->nf_mark = NULL; trace_nfsd_file_alloc(nf); } @@ -958,21 +952,7 @@ wait_for_construction: this_cpu_inc(nfsd_file_cache_hits); - if (!(may_flags & NFSD_MAY_NOT_BREAK_LEASE)) { - bool write = (may_flags & NFSD_MAY_WRITE); - - if (test_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags) || - (test_bit(NFSD_FILE_BREAK_WRITE, &nf->nf_flags) && write)) { - status = nfserrno(nfsd_open_break_lease( - file_inode(nf->nf_file), may_flags)); - if (status == nfs_ok) { - clear_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags); - if (write) - clear_bit(NFSD_FILE_BREAK_WRITE, - &nf->nf_flags); - } - } - } + status = nfserrno(nfsd_open_break_lease(file_inode(nf->nf_file), may_flags)); out: if (status == nfs_ok) { *pnf = nf; --- a/fs/nfsd/filecache.h +++ b/fs/nfsd/filecache.h @@ -37,9 +37,7 @@ struct nfsd_file { struct net *nf_net; #define NFSD_FILE_HASHED (0) #define NFSD_FILE_PENDING (1) -#define NFSD_FILE_BREAK_READ (2) -#define NFSD_FILE_BREAK_WRITE (3) -#define NFSD_FILE_REFERENCED (4) +#define NFSD_FILE_REFERENCED (2) unsigned long nf_flags; struct inode *nf_inode; unsigned int nf_hashval; --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -696,8 +696,6 @@ DEFINE_CLID_EVENT(confirmed_r); __print_flags(val, "|", \ { 1 << NFSD_FILE_HASHED, "HASHED" }, \ { 1 << NFSD_FILE_PENDING, "PENDING" }, \ - { 1 << NFSD_FILE_BREAK_READ, "BREAK_READ" }, \ - { 1 << NFSD_FILE_BREAK_WRITE, "BREAK_WRITE" }, \ { 1 << NFSD_FILE_REFERENCED, "REFERENCED"}) DECLARE_EVENT_CLASS(nfsd_file_class,