Whamcloud - gitweb
LU-812 ldiskfs: super_operations->dirty_inode now takes a flag
[fs/lustre-release.git] / lustre / include / linux / lustre_compat25.h
index d25c168..ca485cd 100644 (file)
@@ -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) \
@@ -750,4 +759,10 @@ static inline struct dentry *d_make_root(struct inode *root)
 }
 #endif
 
+#ifdef HAVE_DIRTY_INODE_HAS_FLAG
+# define ll_dirty_inode(inode, flag)   (inode)->i_sb->s_op->dirty_inode((inode), flag)
+#else
+# define ll_dirty_inode(inode, flag)   (inode)->i_sb->s_op->dirty_inode((inode))
+#endif
+
 #endif /* _COMPAT25_H */