#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) \
}
EXPORT_SYMBOL(lustre_rename);
-/* Note: dput(dchild) will be called if there is an error */
+/* Note: dput(dchild) will *not* be called if there is an error */
struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de,
- int flags)
+ int flags)
{
- mntget(ctxt->pwdmnt);
- return ll_dentry_open(de, ctxt->pwdmnt, flags, current_cred());
+ struct path path = {
+ .dentry = de,
+ .mnt = ctxt->pwdmnt,
+ };
+ return ll_dentry_open(&path, flags, current_cred());
}
EXPORT_SYMBOL(l_dentry_open);
logid->lgl_ogen, rc);
GOTO(out, rc);
}
- /* l_dentry_open will call dput(dchild) if there is an error */
handle->lgh_file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild,
O_RDWR | O_LARGEFILE);
+ l_dput(dchild);
if (IS_ERR(handle->lgh_file)) {
rc = PTR_ERR(handle->lgh_file);
handle->lgh_file = NULL;
GOTO(out, rc = PTR_ERR(dchild));
file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild, open_flags);
+ l_dput(dchild);
if (IS_ERR(file))
GOTO(out, rc = PTR_ERR(file));
handle->lgh_id.lgl_oseq = oa->o_seq;