]) # LC_HAVE_AIO_COMPLETE
#
+# LC_HAVE_IS_ROOT_INODE
+#
+# 3.19 kernel adds is_root_inode()
+# Commit a7400222e3eb ("new helper: is_root_inode()")
+#
+AC_DEFUN([LC_HAVE_IS_ROOT_INODE], [
+LB_CHECK_COMPILE([if kernel has is_root_inode() ],
+is_root_inode, [
+ #include <linux/fs.h>
+],[
+ is_root_inode(NULL);
+],[
+ AC_DEFINE(HAVE_IS_ROOT_INODE, 1, [is_root_inode defined])
+])
+]) # LC_HAVE_IS_ROOT_INODE
+
+#
# LC_BACKING_DEV_INFO_REMOVAL
#
# 3.20 kernel removed backing_dev_info from address_space
LC_KIOCB_HAS_NBYTES
LC_HAVE_DQUOT_QC_DQBLK
LC_HAVE_AIO_COMPLETE
+ LC_HAVE_IS_ROOT_INODE
# 3.20
LC_BACKING_DEV_INFO_REMOVAL
#define raw_cpu_ptr(p) __this_cpu_ptr(p)
#endif
+#ifndef HAVE_IS_ROOT_INODE
+static inline bool is_root_inode(struct inode *inode)
+{
+ return inode == inode->i_sb->s_root->d_inode;
+}
+#endif
+
#endif /* _LUSTRE_COMPAT_H */
}
/* Encrypting the root directory is not allowed */
- if (inode->i_ino == inode->i_sb->s_root->d_inode->i_ino)
+ if (is_root_inode(inode))
return -EPERM;
dentry = (struct dentry *)fs_data;
if (copy_from_user(&lumv1, lumv1p, sizeof(lumv1)))
RETURN(-EFAULT);
- if (inode->i_sb->s_root == file_dentry(file))
+ if (is_root_inode(inode))
set_default = 1;
switch (lumv1.lmm_magic) {
if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd)
ll_deauthorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file_dentry(file)) {
+ if (is_root_inode(inode)) {
file->private_data = NULL;
ll_file_data_put(fd);
GOTO(out, rc = 0);
libcfs_debug_dumplog();
out:
- if (!rc && inode->i_sb->s_root != file_dentry(file))
+ if (!rc && !is_root_inode(inode))
ll_stats_ops_tally(sbi, LPROC_LL_RELEASE,
ktime_us_delta(ktime_get(), kstart));
RETURN(rc);
if (S_ISDIR(inode->i_mode))
ll_authorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file_dentry(file)) {
+ if (is_root_inode(inode)) {
file->private_data = fd;
RETURN(0);
}
*/
int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it)
{
- struct inode *inode = dentry->d_inode;
- struct obd_client_handle *och;
- int rc;
- ENTRY;
+ struct inode *inode = dentry->d_inode;
+ struct obd_client_handle *och;
+ int rc;
+ ENTRY;
- LASSERT(inode);
+ LASSERT(inode);
- /* Root ? Do nothing. */
- if (dentry->d_inode->i_sb->s_root == dentry)
- RETURN(0);
+ /* Root ? Do nothing. */
+ if (is_root_inode(inode))
+ RETURN(0);
- /* No open handle to close? Move away */
- if (!it_disposition(it, DISP_OPEN_OPEN))
- RETURN(0);
+ /* No open handle to close? Move away */
+ if (!it_disposition(it, DISP_OPEN_OPEN))
+ RETURN(0);
- LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0);
+ LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0);
- OBD_ALLOC(och, sizeof(*och));
- if (!och)
- GOTO(out, rc = -ENOMEM);
+ OBD_ALLOC(och, sizeof(*och));
+ if (!och)
+ GOTO(out, rc = -ENOMEM);
rc = ll_och_fill(ll_i2sbi(inode)->ll_md_exp, it, och);
if (rc)
* by checking the migrate FID against the FID of the
* filesystem root.
*/
- if (child_inode == parent->i_sb->s_root->d_inode)
+ if (is_root_inode(child_inode))
GOTO(out_iput, rc = -EINVAL);
op_data = ll_prep_md_op_data(NULL, parent, NULL, name, namelen,
* need to do it before permission check.
*/
- if (inode == inode->i_sb->s_root->d_inode) {
+ if (is_root_inode(inode)) {
rc = ll_inode_revalidate(inode->i_sb->s_root, IT_LOOKUP);
if (rc)
RETURN(rc);
}
if ((bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM)) &&
- inode->i_sb->s_root != NULL &&
- inode != inode->i_sb->s_root->d_inode)
+ !is_root_inode(inode))
ll_prune_aliases(inode);
if (bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM))
if (!rc2) {
fid = &loa->loa_lma.lma_self_fid;
} else if (rc2 == -ENODATA) {
- if (unlikely(parent == inode->i_sb->s_root->d_inode)) {
+ if (unlikely(is_root_inode(parent))) {
fid = &info->oti_fid3;
lu_local_obj_fid(fid, OSD_FS_ROOT_OID);
} else if (!osd->od_is_ost && osd->od_index == 0) {
if (!rc) {
*fid = loa->loa_lma.lma_self_fid;
} else if (rc == -ENODATA) {
- if (unlikely(inode == osd_sb(dev)->s_root->d_inode))
+ if (unlikely(is_root_inode(inode)))
lu_local_obj_fid(fid, OSD_FS_ROOT_OID);
else
lu_igif_build(fid, inode->i_ino, inode->i_generation);
LASSERT(pobj->oo_inode);
ldp = (struct ldiskfs_dentry_param *)info->oti_ldp;
- if (unlikely(pobj->oo_inode ==
- osd_sb(osd_obj2dev(pobj))->s_root->d_inode))
+ if (unlikely(osd_object_is_root(pobj)))
ldp->edp_magic = 0;
else
osd_get_ldiskfs_dirent_param(ldp, fid);
static inline int osd_object_is_root(const struct osd_object *obj)
{
- return osd_sb(osd_obj2dev(obj))->s_root->d_inode == obj->oo_inode;
+ return obj->oo_inode && is_root_inode(obj->oo_inode);
}
static inline struct osd_object *osd_obj(const struct lu_object *o)
osd_index_need_recreate(info->oti_env, dev, inode)) {
struct lu_fid *pfid = &info->oti_fid3;
- if (parent == osd_sb(dev)->s_root->d_inode) {
+ if (is_root_inode(parent)) {
lu_local_obj_fid(pfid, OSD_FS_ROOT_OID);
} else {
rc = osd_scrub_get_fid(info, dev, parent, pfid,