Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21762530ybl; Mon, 6 Jan 2020 10:43:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzg0e20mKLftIozQ4UKY5A9czreap9QvMh1ZriWNyjC+7Bm87vMgqGchW9+eSlExHAIzNVo X-Received: by 2002:a9d:369:: with SMTP id 96mr106917468otv.228.1578336186732; Mon, 06 Jan 2020 10:43:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578336186; cv=none; d=google.com; s=arc-20160816; b=0FEyofHcBZXYY/woKiWOTg6EXDb69aWu26ajg1Dt1m9z127LZ8sOvK01b3wBBbMkTb a+oD9MrcVIQ5EPPeCxzcdx/5KYp0cWujQVEYKuwplHzTtjfGH/5N525DapdVW8XD7IhP 1PGlLb7GSTzG5crmfvjf95a025ULUUsL3tMAjrC94XY97wRPx8WOeolJMY0PBAU8eycm 0JkX4isI4vV70yQ6N4hHJI0aEyasQDUB3qre5fpooNQPbe31u63EDH8Vdj+BywP7Sq13 70RtbpraDICwzvYMnu/uHwYtT+x6dqMrI926ELY2odb1A34hOBoCEaHWkog3pP8vWRG4 zuVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3gv2Uv5Vo9nayPlWr/mLsAQL4tqjnJ1W4jdHwtQk72w=; b=v8syFjMQLoIHdP00H5sj0UJ3bX7Fd3fqoo95a++7H0ppyLOlnkilEdEhjyTrynnbc5 uzTN57pNbN/AgObq+XpO1zn26fmqQrXw6APOiCZaeymniE7p04BCaw1j+3AVSAjpWhZG wQfd2PmiQh0Nf5ov5ZUJ+jyHaXcciooUUQlrkjETgTTwmiPkDaTS+L8FfKZ5EO0QNbnz 603xtUiPdsQbms8ogu05WbJSXzJiLKyGxAwMnVBwBRUXgzqsRgKL7c25fGHoAILFJ5kA 4FIS3EsGY6s4yW2I4GOIC7nWjkyJ+Opq6faR23SWSjhrvECqYSph6wQb2DSUsNdmZHbR pAlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A0RVLw9U; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si32106654otq.96.2020.01.06.10.42.56; Mon, 06 Jan 2020 10:43:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A0RVLw9U; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbgAFSmy (ORCPT + 99 others); Mon, 6 Jan 2020 13:42:54 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:32892 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbgAFSmx (ORCPT ); Mon, 6 Jan 2020 13:42:53 -0500 Received: by mail-yb1-f193.google.com with SMTP id n66so22489640ybg.0 for ; Mon, 06 Jan 2020 10:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3gv2Uv5Vo9nayPlWr/mLsAQL4tqjnJ1W4jdHwtQk72w=; b=A0RVLw9UXvaoCqp5O7Z4MoKjy+n56Ui1CkGZfxChF8rkE00M5WIRJ52jppBAZL6X4X WrYYp6YRJ9n5e9pRaUYip3LuIAcCgAYYtNHGFKngztRnizt++suTFj08+o2t090WTHYg Qpd51hwnb25HgvXyDQD6O+Y6AfUn/OJSbv9d1+r4FCj1dy+t56kMbkypso2PJ0TtXzHc Wy2VBO1xeW/aMyK9YxgmT/KiOdzs6yMfcxLt0uuBU0KR/dNTbhpXVHvu4elQtQ0tGwYO 4pM/e9paC+al0X7/mYsNxOtFk8/2aubQXRtROuyWgo7JI9AIPqlJ4sFyvVTRu5JVHYL8 R6rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3gv2Uv5Vo9nayPlWr/mLsAQL4tqjnJ1W4jdHwtQk72w=; b=nGOFUAY8lmKSEh2MYc59PKDrO7xC2rQRG6jW4fvlgucCI81sAk4T32NYSx6mBG9hZ0 Qh+gbkPGXJ/vOlIqwxPj6hjtKBs6B67kKCElBD9vPZgOULQAnGLWajmi7w30D85lhkN1 D/ON5waWL/SA9pGhImH8SUp6MJXSzDYerMxWXlRGEk3iScsAGk7jZXWazvr9qHB6Ozy6 LvHDccGcLAsP7BQNdAQ5fL2MIJc54clVbZfABSdUGobYZaF5GZc8JC+i8HYJNQwNMHSL Y1bvGGKO/1eHUDUpMeb/FsZTNY7DAMp0vRIxcnqxgoecnZq+Cxmo34PoXiJVWvxA8Oft 52AA== X-Gm-Message-State: APjAAAVikiulf6TqsDnFtnbbTbqK5j2tcK8HfILoku5eOCcjn3KyMXdT 7TrmgNGDTB9tc784YLFfTA== X-Received: by 2002:a25:d88d:: with SMTP id p135mr79102374ybg.205.1578336172532; Mon, 06 Jan 2020 10:42:52 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id u136sm28223497ywf.101.2020.01.06.10.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 10:42:52 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: "J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH 5/9] nfsd: Ensure exclusion between CLONE and WRITE errors Date: Mon, 6 Jan 2020 13:40:33 -0500 Message-Id: <20200106184037.563557-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200106184037.563557-5-trond.myklebust@hammerspace.com> References: <20200106184037.563557-1-trond.myklebust@hammerspace.com> <20200106184037.563557-2-trond.myklebust@hammerspace.com> <20200106184037.563557-3-trond.myklebust@hammerspace.com> <20200106184037.563557-4-trond.myklebust@hammerspace.com> <20200106184037.563557-5-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Ensure that we can distinguish between synchronous CLONE and WRITE errors, and that we can assign them correctly. Signed-off-by: Trond Myklebust --- fs/nfsd/vfs.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 7e7e31dfc672..b2984a996ab8 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -536,22 +536,33 @@ __be32 nfsd4_clone_file_range(struct nfsd_file *nf_src, u64 src_pos, struct file *src = nf_src->nf_file; struct file *dst = nf_dst->nf_file; loff_t cloned; + __be32 ret = 0; + down_write(&nf_dst->nf_rwsem); cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0); - if (cloned < 0) - return nfserrno(cloned); - if (count && cloned != count) - return nfserrno(-EINVAL); + if (cloned < 0) { + ret = nfserrno(cloned); + goto out_err; + } + if (count && cloned != count) { + ret = nfserrno(-EINVAL); + goto out_err; + } if (sync) { loff_t dst_end = count ? dst_pos + count - 1 : LLONG_MAX; int status = vfs_fsync_range(dst, dst_pos, dst_end, 0); if (!status) status = commit_inode_metadata(file_inode(src)); - if (status < 0) - return nfserrno(status); + if (status < 0) { + nfsd_reset_boot_verifier(net_generic(nf_dst->nf_net, + nfsd_net_id)); + ret = nfserrno(status); + } } - return 0; +out_err: + up_write(&nf_dst->nf_rwsem); + return ret; } ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst, -- 2.24.1