X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Flinux%2Flustre_compat25.h;h=e0a29ff5a7531fa9a43a5185d5c34eaa11a76ebc;hp=d25c168f58029ad6bdb0d89157e273491a3b7cb2;hb=1e149bef8d832aade6c04b65b8308b71c6d523ed;hpb=34d5ccc193c948c5946f2363976de09eb0f2ab10 diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index d25c168..e0a29ff 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -140,19 +140,28 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define ll_blkdev_put(a, b) blkdev_put(a) #endif -static inline struct file *ll_dentry_open(struct dentry *dentry, - struct vfsmount *mnt, int flags, - const struct cred *cred) -{ #ifdef HAVE_DENTRY_OPEN_USE_PATH - struct path path = { .mnt = mnt, .dentry = dentry }; - return dentry_open(&path, flags, cred); -#elif defined HAVE_DENTRY_OPEN_4ARGS - return dentry_open(dentry, mnt, flags, cred); +#define ll_dentry_open(a,b,c) dentry_open(a,b,c) #else - return dentry_open(dentry, mnt, flags); -#endif +/* + * dentry_open handles its own reference counting since Linux v3.6 + * (commit 765927b2). Callers should free their own references. + * + * Prior versions expected the caller to increment the references. + * The references are retained on success and freed on error. + */ +static inline struct file *ll_dentry_open(struct path *path, int flags, + const struct cred *cred) +{ + mntget(path->mnt); + dget(path->dentry); +# ifdef HAVE_DENTRY_OPEN_4ARGS + return dentry_open(path->dentry, path->mnt, flags, cred); +# else + return dentry_open(path->dentry, path->mnt, flags); +# endif } +#endif #ifdef HAVE_SECURITY_PLUG #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \