From db5abf4b2b3fadc054a4e7d0d5a6b2fd9a99023c Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Fri, 11 Jul 2014 00:30:54 -0400 Subject: [PATCH] LU-4367 llite: Make revalidate return 0 for opens This is important so that we can properly engage opencache when needed. This also reshuffles some other logic in ll_revalidate_dentry to more properly handle intermediate component revalidate logic. Change-Id: Ib4f272155096d33fe3f45b781e21e5bd4f44ff58 Signed-off-by: Oleg Drokin Reviewed-on: http://review.whamcloud.com/11062 Tested-by: Jenkins Reviewed-by: Niu Yawei Reviewed-by: Lai Siyao Tested-by: Maloo --- lustre/llite/dcache.c | 25 ++++++++++++++++--------- lustre/llite/file.c | 5 +++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 2d3d2f7..7243769 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -358,18 +358,25 @@ static int ll_revalidate_dentry(struct dentry *dentry, { struct inode *dir = dentry->d_parent->d_inode; - /* - * if open&create is set, talk to MDS to make sure file is created if - * necessary, because we can't do this in ->open() later since that's - * called on an inode. return 0 here to let lookup to handle this. - */ - if ((lookup_flags & (LOOKUP_OPEN | LOOKUP_CREATE)) == - (LOOKUP_OPEN | LOOKUP_CREATE)) - return 0; + /* If this is intermediate component path lookup and we were able to get + * to this dentry, then its lock has not been revoked and the + * path component is valid. */ + if (lookup_flags & (LOOKUP_CONTINUE | LOOKUP_PARENT)) + return 1; - if (lookup_flags & (LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE)) + /* Symlink - always valid as long as the dentry was found */ + if (dentry->d_inode && dentry->d_inode->i_op->follow_link) return 1; + /* Last path component lookup for open or create - we always + * return 0 here to go through re-lookup and properly signal + * MDS whenever we do or do not want an open-cache to be engaged. + * For create we also ensure the entry is really created no matter + * what races might have happened. + * LU-4367 */ + if (lookup_flags & (LOOKUP_OPEN | LOOKUP_CREATE)) + return 0; + if (d_need_statahead(dir, dentry) <= 0) return 1; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 0457867..52fc9ff 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -666,8 +666,9 @@ restart: /* * Normally called under two situations: * 1. NFS export. - * 2. revalidate with IT_OPEN (revalidate doesn't - * execute this intent any more). + * 2. A race/condition on MDS resulting in no open + * handle to be returned from LOOKUP|OPEN request, + * for example if the target entry was a symlink. * * Always fetch MDS_OPEN_LOCK if this is not setstripe. * -- 1.8.3.1