All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: "Yan, Zheng" <zyan@redhat.com>, ceph-devel@vger.kernel.org
Cc: sage@redhat.com, idryomov@gmail.com, pdonnell@redhat.com,
	xiubli@redhat.com
Subject: Re: [RFC PATCH v2 10/10] ceph: attempt to do async create when possible
Date: Fri, 17 Jan 2020 12:40:43 -0500	[thread overview]
Message-ID: <3d8442090c4590903425f8800dad7c504898b4ec.camel@kernel.org> (raw)
In-Reply-To: <05265520-30e8-1d88-c2f1-863308de31d1@redhat.com>

On Fri, 2020-01-17 at 21:28 +0800, Yan, Zheng wrote:
> On 1/16/20 4:59 AM, Jeff Layton wrote:
> > With the Octopus release, the MDS will hand out directory create caps.
> > 
> > If we have Fxc caps on the directory, and complete directory information
> > or a known negative dentry, then we can return without waiting on the
> > reply, allowing the open() call to return very quickly to userland.
> > 
> > We use the normal ceph_fill_inode() routine to fill in the inode, so we
> > have to gin up some reply inode information with what we'd expect the
> > newly-created inode to have. The client assumes that it has a full set
> > of caps on the new inode, and that the MDS will revoke them when there
> > is conflicting access.
> > 
> > This functionality is gated on the enable_async_dirops module option,
> > along with async unlinks, and on the server supporting the necessary
> > CephFS feature bit.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >   fs/ceph/file.c               | 196 +++++++++++++++++++++++++++++++++--
> >   include/linux/ceph/ceph_fs.h |   3 +
> >   2 files changed, 190 insertions(+), 9 deletions(-)
> > 
> > diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> > index b44ccbc85fe4..2742417fa5ec 100644
> > --- a/fs/ceph/file.c
> > +++ b/fs/ceph/file.c
> > @@ -448,6 +448,169 @@ cache_file_layout(struct inode *dst, struct inode *src)
> >   	spin_unlock(&cdst->i_ceph_lock);
> >   }
> >   
> > +/*
> > + * Try to set up an async create. We need caps, a file layout, and inode number,
> > + * and either a lease on the dentry or complete dir info. If any of those
> > + * criteria are not satisfied, then return false and the caller can go
> > + * synchronous.
> > + */
> > +static bool try_prep_async_create(struct inode *dir, struct dentry *dentry,
> > +				  struct ceph_file_layout *lo,
> > +				  unsigned long *pino)
> > +{
> > +	struct ceph_inode_info *ci = ceph_inode(dir);
> > +	bool ret = false;
> > +	unsigned long ino;
> > +
> > +	spin_lock(&ci->i_ceph_lock);
> > +	/* No auth cap means no chance for Dc caps */
> > +	if (!ci->i_auth_cap)
> > +		goto no_async;
> > +
> > +	/* Any delegated inos? */
> > +	if (xa_empty(&ci->i_auth_cap->session->s_delegated_inos))
> > +		goto no_async;
> > +
> > +	if (!ceph_file_layout_is_valid(&ci->i_cached_layout))
> > +		goto no_async;
> > +
> > +	/* Use LOOKUP_RCU since we're under i_ceph_lock */
> > +	if (!__ceph_dir_is_complete(ci) &&
> > +	    !dentry_lease_is_valid(dentry, LOOKUP_RCU))
> > +		goto no_async;
> 
> dentry_lease_is_valid() checks dentry lease. When directory inode has
> Fsx caps, mds does not issue lease for individual dentry. Check here 
> should be something like dir_lease_is_valid()

Ok, I think I get it. The catch here is that we're calling this from
atomic_open, so we may be dealing with a dentry that is brand new and
has never had a lookup. I think we have to handle those two cases
differently.

This is what I'm thinking:

---
 fs/ceph/file.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 7b14dba92266..a3eb38fac68a 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -459,6 +459,7 @@ static bool try_prep_async_create(struct inode *dir,
struct dentry *dentry,
 				  unsigned long *pino)
 {
 	struct ceph_inode_info *ci = ceph_inode(dir);
+	struct ceph_dentry_info *di = ceph_dentry(dentry);
 	bool ret = false;
 	unsigned long ino;
 
@@ -474,16 +475,19 @@ static bool try_prep_async_create(struct inode
*dir, struct dentry *dentry,
 	if (!ceph_file_layout_is_valid(&ci->i_cached_layout))
 		goto no_async;
 
-	/* Use LOOKUP_RCU since we're under i_ceph_lock */
-	if (!__ceph_dir_is_complete(ci) &&
-	    !dentry_lease_is_valid(dentry, LOOKUP_RCU))
-		goto no_async;
-
 	if ((__ceph_caps_issued(ci, NULL) &
 	     (CEPH_CAP_FILE_EXCL | CEPH_CAP_DIR_CREATE)) !=
 	    (CEPH_CAP_FILE_EXCL | CEPH_CAP_DIR_CREATE))
 		goto no_async;
 
+	if (d_in_lookup(dentry)) {
+		if (!__ceph_dir_is_complete(ci))
+			goto no_async;
+	} else if (atomic_read(&ci->i_shared_gen) !=
+		   READ_ONCE(di->lease_shared_gen)) {
+		goto no_async;
+	}
+
 	ino = ceph_get_deleg_ino(ci->i_auth_cap->session);
 	if (!ino)
 		goto no_async;
-- 
2.24.1

  reply	other threads:[~2020-01-17 17:40 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 20:59 [RFC PATCH v2 00/10] ceph: asynchronous file create support Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 01/10] libceph: export ceph_file_layout_is_valid Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 02/10] ceph: make ceph_fill_inode non-static Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 03/10] ceph: make dentry_lease_is_valid non-static Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 04/10] ceph: make __take_cap_refs a public function Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 05/10] ceph: decode interval_sets for delegated inos Jeff Layton
2020-01-16 14:32   ` Yan, Zheng
2020-01-16 15:37     ` Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 06/10] ceph: add flag to designate that a request is asynchronous Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 07/10] ceph: add infrastructure for waiting for async create to complete Jeff Layton
2020-01-17 15:00   ` Ilya Dryomov
2020-01-17 16:49     ` Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 08/10] ceph: add new MDS req field to hold delegated inode number Jeff Layton
2020-01-17 14:47   ` Ilya Dryomov
2020-01-17 16:53     ` Jeff Layton
2020-01-17 17:42       ` Ilya Dryomov
2020-01-17 18:31         ` Jeff Layton
2020-01-20  9:41           ` Ilya Dryomov
2020-01-15 20:59 ` [RFC PATCH v2 09/10] ceph: cache layout in parent dir on first sync create Jeff Layton
2020-01-15 20:59 ` [RFC PATCH v2 10/10] ceph: attempt to do async create when possible Jeff Layton
2020-01-16 15:09   ` Yan, Zheng
2020-01-16 16:21     ` Jeff Layton
2020-01-17 13:28   ` Yan, Zheng
2020-01-17 17:40     ` Jeff Layton [this message]
2020-01-18  2:42       ` Yan, Zheng
2020-01-15 21:30 ` [RFC PATCH v2 00/10] ceph: asynchronous file create support Jeff Layton
2020-01-16  8:57 ` Xiubo Li
2020-01-16 13:10 ` Yan, Zheng
2020-01-16 14:15   ` Jeff Layton
2020-01-20 13:20 ` Yan, Zheng
2020-01-21 10:56   ` Jeff Layton
2020-01-21 13:20     ` Yan, Zheng
2020-01-21 14:37       ` Jeff Layton

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=3d8442090c4590903425f8800dad7c504898b4ec.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=pdonnell@redhat.com \
    --cc=sage@redhat.com \
    --cc=xiubli@redhat.com \
    --cc=zyan@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.