From: Shaun Tancheff Date: Thu, 10 Oct 2019 04:49:36 +0000 (-0700) Subject: LU-12355 llite: vfs atomic_open change with FMODE_CREATED X-Git-Tag: 2.12.4-RC1~90 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=8f5922a924de71b6a732eb7d2d2b50d58ecb0996;p=fs%2Flustre-release.git LU-12355 llite: vfs atomic_open change with FMODE_CREATED Kernel 4.19 introduced FMODE_CREATED and switched to it while the last argument to vfs atomic_open was removed and the f_mode flags are used to indicate the created state on return. Linux-commit: 73a09dd94377e4b186b300bd5461920710c7c3d5 Lustre-change: https://review.whamcloud.com/35020 Lustre-commit: 4decb4c2da6053066f10cbe419e2db212de8e4aa Test-Parameters: trivial Change-Id: I26d4aadb123bb1d1bc0aa1d78a64a75b94276ffb Signed-off-by: Shaun Tancheff Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Thomas Stibor Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/36415 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index f12fdbb..3cfc768 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -859,13 +859,33 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, return de; } +#ifdef FMODE_CREATED /* added in Linux v4.18-rc1-20-g73a09dd */ +# define ll_is_opened(o, f) ((f)->f_mode & FMODE_OPENED) +# define ll_finish_open(f, d, o) finish_open((f), (d), NULL) +# define ll_last_arg +# define ll_set_created(o, f) \ +do { \ + (f)->f_mode |= FMODE_CREATED; \ +} while (0) + +#else +# define ll_is_opened(o, f) (*(o)) +# define ll_finish_open(f, d, o) finish_open((f), (d), NULL, (o)) +# define ll_last_arg , int *opened +# define ll_set_created(o, f) \ +do { \ + *(o) |= FILE_CREATED; \ +} while (0) + +#endif + /* * For cached negative dentry and new dentry, handle lookup/create/open * together. */ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, struct file *file, unsigned open_flags, - umode_t mode, int *opened) + umode_t mode ll_last_arg) { struct lookup_intent *it; struct dentry *de; @@ -878,7 +898,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s, dir="DFID"(%p), file %p," "open_flags %x, mode %x opened %d\n", dentry->d_name.len, dentry->d_name.name, - PFID(ll_inode2fid(dir)), dir, file, open_flags, mode, *opened); + PFID(ll_inode2fid(dir)), dir, file, open_flags, mode, + ll_is_opened(opened, file)); /* Only negative dentries enter here */ LASSERT(dentry->d_inode == NULL); @@ -931,8 +952,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, dput(de); goto out_release; } - - *opened |= FILE_CREATED; + ll_set_created(opened, file); } if (dentry->d_inode && it_disposition(it, DISP_OPEN_OPEN)) { /* Open dentry. */ @@ -943,7 +963,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, rc = finish_no_open(file, de); } else { file->private_data = it; - rc = finish_open(file, dentry, NULL, opened); + rc = ll_finish_open(file, dentry, opened); /* We dget in ll_splice_alias. finish_open takes * care of dget for fd open. */