linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 5.4 35/65] nfsd: clients dont need to break their own delegations
Date: Tue, 7 Jul 2020 11:31:22 -0400	[thread overview]
Message-ID: <20200707153122.GA171624@pick.fieldses.org> (raw)
In-Reply-To: <20200707145754.171869800@linuxfoundation.org>

NACK.

(How did this one even end up headed for stable?  It wasn't cc'd to
stable, it's not a bugfix, and it's not a small patch.)

--b.

On Tue, Jul 07, 2020 at 05:17:14PM +0200, Greg Kroah-Hartman wrote:
> From: J. Bruce Fields <bfields@redhat.com>
> 
> [ Upstream commit 28df3d1539de5090f7916f6fff03891b67f366f4 ]
> 
> We currently revoke read delegations on any write open or any operation
> that modifies file data or metadata (including rename, link, and
> unlink).  But if the delegation in question is the only read delegation
> and is held by the client performing the operation, that's not really
> necessary.
> 
> It's not always possible to prevent this in the NFSv4.0 case, because
> there's not always a way to determine which client an NFSv4.0 delegation
> came from.  (In theory we could try to guess this from the transport
> layer, e.g., by assuming all traffic on a given TCP connection comes
> from the same client.  But that's not really correct.)
> 
> In the NFSv4.1 case the session layer always tells us the client.
> 
> This patch should remove such self-conflicts in all cases where we can
> reliably determine the client from the compound.
> 
> To do that we need to track "who" is performing a given (possibly
> lease-breaking) file operation.  We're doing that by storing the
> information in the svc_rqst and using kthread_data() to map the current
> task back to a svc_rqst.
> 
> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  Documentation/filesystems/locking.rst |  2 ++
>  fs/locks.c                            |  3 +++
>  fs/nfsd/nfs4proc.c                    |  2 ++
>  fs/nfsd/nfs4state.c                   | 14 ++++++++++++++
>  fs/nfsd/nfsd.h                        |  2 ++
>  fs/nfsd/nfssvc.c                      |  6 ++++++
>  include/linux/fs.h                    |  1 +
>  include/linux/sunrpc/svc.h            |  1 +
>  8 files changed, 31 insertions(+)
> 
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index fc3a0704553cf..b5f8d15a30fb7 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -425,6 +425,7 @@ prototypes::
>  	int (*lm_grant)(struct file_lock *, struct file_lock *, int);
>  	void (*lm_break)(struct file_lock *); /* break_lease callback */
>  	int (*lm_change)(struct file_lock **, int);
> +	bool (*lm_breaker_owns_lease)(struct file_lock *);
>  
>  locking rules:
>  
> @@ -435,6 +436,7 @@ lm_notify:		yes		yes			no
>  lm_grant:		no		no			no
>  lm_break:		yes		no			no
>  lm_change		yes		no			no
> +lm_breaker_owns_lease:	no		no			no
>  ==========		=============	=================	=========
>  
>  buffer_head
> diff --git a/fs/locks.c b/fs/locks.c
> index b8a31c1c4fff3..a3f186846e93e 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1557,6 +1557,9 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
>  {
>  	bool rc;
>  
> +	if (lease->fl_lmops->lm_breaker_owns_lease
> +			&& lease->fl_lmops->lm_breaker_owns_lease(lease))
> +		return false;
>  	if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT)) {
>  		rc = false;
>  		goto trace;
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index 4798667af647c..96fa2837d3cfb 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1961,6 +1961,8 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
>  		goto encode_op;
>  	}
>  
> +	rqstp->rq_lease_breaker = (void **)&cstate->clp;
> +
>  	trace_nfsd_compound(rqstp, args->opcnt);
>  	while (!status && resp->opcnt < args->opcnt) {
>  		op = &args->ops[resp->opcnt++];
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 8650a97e2ba96..1e8f5e281bb53 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4464,6 +4464,19 @@ nfsd_break_deleg_cb(struct file_lock *fl)
>  	return ret;
>  }
>  
> +static bool nfsd_breaker_owns_lease(struct file_lock *fl)
> +{
> +	struct nfs4_delegation *dl = fl->fl_owner;
> +	struct svc_rqst *rqst;
> +	struct nfs4_client *clp;
> +
> +	if (!i_am_nfsd())
> +		return NULL;
> +	rqst = kthread_data(current);
> +	clp = *(rqst->rq_lease_breaker);
> +	return dl->dl_stid.sc_client == clp;
> +}
> +
>  static int
>  nfsd_change_deleg_cb(struct file_lock *onlist, int arg,
>  		     struct list_head *dispose)
> @@ -4475,6 +4488,7 @@ nfsd_change_deleg_cb(struct file_lock *onlist, int arg,
>  }
>  
>  static const struct lock_manager_operations nfsd_lease_mng_ops = {
> +	.lm_breaker_owns_lease = nfsd_breaker_owns_lease,
>  	.lm_break = nfsd_break_deleg_cb,
>  	.lm_change = nfsd_change_deleg_cb,
>  };
> diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
> index af2947551e9ce..7a835fb7d79f7 100644
> --- a/fs/nfsd/nfsd.h
> +++ b/fs/nfsd/nfsd.h
> @@ -87,6 +87,8 @@ int		nfsd_pool_stats_release(struct inode *, struct file *);
>  
>  void		nfsd_destroy(struct net *net);
>  
> +bool		i_am_nfsd(void);
> +
>  struct nfsdfs_client {
>  	struct kref cl_ref;
>  	void (*cl_release)(struct kref *kref);
> diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
> index e8bee8ff30c59..cb7f0aa9a3b05 100644
> --- a/fs/nfsd/nfssvc.c
> +++ b/fs/nfsd/nfssvc.c
> @@ -590,6 +590,11 @@ static const struct svc_serv_ops nfsd_thread_sv_ops = {
>  	.svo_module		= THIS_MODULE,
>  };
>  
> +bool i_am_nfsd()
> +{
> +	return kthread_func(current) == nfsd;
> +}
> +
>  int nfsd_create_serv(struct net *net)
>  {
>  	int error;
> @@ -997,6 +1002,7 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
>  		*statp = rpc_garbage_args;
>  		return 1;
>  	}
> +	rqstp->rq_lease_breaker = NULL;
>  	/*
>  	 * Give the xdr decoder a chance to change this if it wants
>  	 * (necessary in the NFSv4.0 compound case)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5bd384dbdca58..4b5b7667405d8 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1040,6 +1040,7 @@ struct lock_manager_operations {
>  	bool (*lm_break)(struct file_lock *);
>  	int (*lm_change)(struct file_lock *, int, struct list_head *);
>  	void (*lm_setup)(struct file_lock *, void **);
> +	bool (*lm_breaker_owns_lease)(struct file_lock *);
>  };
>  
>  struct lock_manager {
> diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
> index 1afe38eb33f7e..ab6e12d9fcf61 100644
> --- a/include/linux/sunrpc/svc.h
> +++ b/include/linux/sunrpc/svc.h
> @@ -299,6 +299,7 @@ struct svc_rqst {
>  	struct net		*rq_bc_net;	/* pointer to backchannel's
>  						 * net namespace
>  						 */
> +	void **			rq_lease_breaker; /* The v4 client breaking a lease */
>  };
>  
>  #define SVC_NET(rqst) (rqst->rq_xprt ? rqst->rq_xprt->xpt_net : rqst->rq_bc_net)
> -- 
> 2.25.1
> 
> 
> 


  reply	other threads:[~2020-07-07 15:31 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 15:16 [PATCH 5.4 00/65] 5.4.51-rc1 review Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 01/65] io_uring: make sure async workqueue is canceled on exit Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 02/65] mm: fix swap cache node allocation mask Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 03/65] EDAC/amd64: Read back the scrub rate PCI register on F15h Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 04/65] usbnet: smsc95xx: Fix use-after-free after removal Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 05/65] sched/debug: Make sd->flags sysctl read-only Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 06/65] mm/slub.c: fix corrupted freechain in deactivate_slab() Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 07/65] mm/slub: fix stack overruns with SLUB_STATS Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 08/65] rxrpc: Fix race between incoming ACK parser and retransmitter Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 09/65] usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 10/65] tools lib traceevent: Add append() function helper for appending strings Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 11/65] tools lib traceevent: Handle __attribute__((user)) in field names Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 12/65] s390/debug: avoid kernel warning on too large number of pages Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 13/65] nvme-multipath: set bdi capabilities once Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 14/65] nvme: fix possible deadlock when I/O is blocked Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 15/65] nvme-multipath: fix deadlock between ana_work and scan_work Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 16/65] nvme-multipath: fix deadlock due to head->lock Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 17/65] nvme-multipath: fix bogus request queue reference put Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 18/65] kgdb: Avoid suspicious RCU usage warning Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 19/65] selftests: tpm: Use /bin/sh instead of /bin/bash Greg Kroah-Hartman
2020-07-07 15:16 ` [PATCH 5.4 20/65] tpm: Fix TIS locality timeout problems Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 21/65] crypto: af_alg - fix use-after-free in af_alg_accept() due to bh_lock_sock() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 22/65] drm/msm/dpu: fix error return code in dpu_encoder_init Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 23/65] rxrpc: Fix afs large storage transmission performance drop Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 24/65] RDMA/counter: Query a counter before release Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 25/65] cxgb4: use unaligned conversion for fetching timestamp Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 26/65] cxgb4: parse TC-U32 key values and masks natively Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 27/65] cxgb4: fix endian conversions for L4 ports in filters Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 28/65] cxgb4: use correct type for all-mask IP address comparison Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 29/65] cxgb4: fix SGE queue dump destination buffer context Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 30/65] hwmon: (max6697) Make sure the OVERT mask is set correctly Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 31/65] hwmon: (acpi_power_meter) Fix potential memory leak in acpi_power_meter_add() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 32/65] thermal/drivers/mediatek: Fix bank number settings on mt8183 Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 33/65] thermal/drivers/rcar_gen3: Fix undefined temperature if negative Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 34/65] kthread: save thread function Greg Kroah-Hartman
2020-07-07 15:31   ` J. Bruce Fields
2020-07-07 15:17 ` [PATCH 5.4 35/65] nfsd: clients dont need to break their own delegations Greg Kroah-Hartman
2020-07-07 15:31   ` J. Bruce Fields [this message]
2020-07-07 17:20     ` Sasha Levin
2020-07-07 17:29       ` Sasha Levin
2020-07-07 17:31         ` J. Bruce Fields
2020-07-07 15:17 ` [PATCH 5.4 36/65] nfsd4: fix nfsdfs reference count loop Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 37/65] nfsd: fix nfsdfs inode reference count leak Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 38/65] drm: sun4i: hdmi: Remove extra HPD polling Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 39/65] virtio-blk: free vblk-vqs in error path of virtblk_probe() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 40/65] SMB3: Honor posix flag for multiuser mounts Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 41/65] nvme: fix identify error status silent ignore Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 42/65] nvme: fix a crash in nvme_mpath_add_disk Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 43/65] samples/vfs: avoid warning in statx override Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 44/65] i2c: algo-pca: Add 0x78 as SCL stuck low status for PCA9665 Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 45/65] i2c: mlxcpld: check correct size of maximum RECV_LEN packet Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 46/65] spi: spi-fsl-dspi: Fix external abort on interrupt in resume or exit paths Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 47/65] nfsd: apply umask on fs without ACL support Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 48/65] Revert "ALSA: usb-audio: Improve frames size computation" Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 49/65] SMB3: Honor seal flag for multiuser mounts Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 50/65] SMB3: Honor persistent/resilient handle flags " Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 51/65] SMB3: Honor lease disabling " Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 52/65] SMB3: Honor handletimeout flag " Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 53/65] cifs: Fix the target file was deleted when rename failed Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 54/65] MIPS: lantiq: xway: sysctrl: fix the GPHY clock alias names Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 55/65] MIPS: Add missing EHB in mtc0 -> mfc0 sequence for DSPen Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 56/65] drm/amd/display: Only revalidate bandwidth on medium and fast updates Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 57/65] drm/amdgpu: use %u rather than %d for sclk/mclk Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 58/65] drm/amdgpu/atomfirmware: fix vram_info fetching for renoir Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 59/65] dma-buf: Move dma_buf_release() from fops to dentry_ops Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 60/65] irqchip/gic: Atomically update affinity Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 61/65] mm, compaction: fully assume capture is not NULL in compact_zone_order() Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 62/65] mm, compaction: make capture control handling safe wrt interrupts Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 63/65] x86/resctrl: Fix memory bandwidth counter width for AMD Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 64/65] dm zoned: assign max_io_len correctly Greg Kroah-Hartman
2020-07-07 15:17 ` [PATCH 5.4 65/65] efi: Make it possible to disable efivar_ssdt entirely Greg Kroah-Hartman
2020-07-08  5:30 ` [PATCH 5.4 00/65] 5.4.51-rc1 review Naresh Kamboju
2020-07-08  8:41 ` Jon Hunter
2020-07-08 15:15   ` Greg Kroah-Hartman
2020-07-08 16:58     ` Jon Hunter
2020-07-09  9:30       ` Greg Kroah-Hartman
2020-07-08 15:00 ` Shuah Khan
2020-07-08 17:53 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200707153122.GA171624@pick.fieldses.org \
    --to=bfields@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).