Whamcloud - gitweb
LU-17172 lov: include FID in some lov asserts
[fs/lustre-release.git] / lustre / llite / llite_foreign_symlink.c
index c36f363..e5d28cf 100644 (file)
@@ -203,7 +203,7 @@ static int ll_foreign_symlink_parse(struct ll_sb_info *sbi,
         * of foreign LOV is relative path of faked symlink destination,
         * to be completed by prefix
         */
-       if (!(sbi->ll_flags & LL_SBI_FOREIGN_SYMLINK_UPCALL))
+       if (!test_bit(LL_SBI_FOREIGN_SYMLINK_UPCALL, sbi->ll_flags))
                rc = ll_foreign_symlink_default_parse(sbi, inode, lfm,
                                                      destname);
        else /* upcall is available */
@@ -219,6 +219,7 @@ static int ll_foreign_readlink_internal(struct inode *inode, char **symname)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
        struct ll_sb_info *sbi = ll_i2sbi(inode);
+       struct lmv_stripe_object *lsm_obj = NULL;
        struct lov_foreign_md *lfm = NULL;
        char *destname = NULL;
        size_t lfm_size = 0;
@@ -278,8 +279,11 @@ static int ll_foreign_readlink_internal(struct inode *inode, char **symname)
                 * and LMV formats are identical, and then we also only need
                 * one set of parsing routines for both foreign files and dirs!
                 */
-               lfm = (struct lov_foreign_md *)(lli->lli_lsm_md);
-               if (lfm != NULL) {
+               lsm_obj = lmv_stripe_object_get(lli->lli_lsm_obj);
+               up_read(&lli->lli_lsm_sem);
+
+               if (lsm_obj != NULL) {
+                       lfm = (struct lov_foreign_md *)&lsm_obj->lso_lfm;
                        CDEBUG(D_INFO, "%s: inode "DFID": LMV cached found\n",
                               sbi->ll_fsname, PFID(ll_inode2fid(inode)));
                } else {
@@ -299,7 +303,7 @@ static int ll_foreign_readlink_internal(struct inode *inode, char **symname)
 
 failed:
        if (S_ISDIR(inode->i_mode))
-               up_read(&lli->lli_lsm_sem);
+               lmv_stripe_object_put(&lsm_obj);
 
        if (S_ISREG(inode->i_mode) && lfm)
                OBD_FREE(lfm, lfm_size);
@@ -430,15 +434,15 @@ static struct dentry *ll_foreign_dir_lookup(struct inode *parent,
 
 static bool has_same_mount_namespace(struct ll_sb_info *sbi)
 {
-       int rc;
+       bool same;
 
-       rc = (sbi->ll_mnt.mnt == current->fs->root.mnt);
-       if (!rc)
+       same = (sbi->ll_mnt_ns == current->nsproxy->mnt_ns);
+       if (!same)
                LCONSOLE_WARN("%s: client mount %s and '%s.%d' not in same mnt-namespace\n",
                              sbi->ll_fsname, sbi->ll_kset.kobj.name,
                              current->comm, current->pid);
 
-       return rc;
+       return same;
 }
 
 ssize_t foreign_symlink_enable_show(struct kobject *kobj,
@@ -448,7 +452,7 @@ ssize_t foreign_symlink_enable_show(struct kobject *kobj,
                                              ll_kset.kobj);
 
        return snprintf(buf, PAGE_SIZE, "%d\n",
-                       !!(sbi->ll_flags & LL_SBI_FOREIGN_SYMLINK));
+                       test_bit(LL_SBI_FOREIGN_SYMLINK, sbi->ll_flags));
 }
 
 /*
@@ -475,9 +479,9 @@ ssize_t foreign_symlink_enable_store(struct kobject *kobj,
                return rc;
 
        if (val)
-               sbi->ll_flags |= LL_SBI_FOREIGN_SYMLINK;
+               set_bit(LL_SBI_FOREIGN_SYMLINK, sbi->ll_flags);
        else
-               sbi->ll_flags &= ~LL_SBI_FOREIGN_SYMLINK;
+               clear_bit(LL_SBI_FOREIGN_SYMLINK, sbi->ll_flags);
 
        return count;
 }
@@ -609,7 +613,7 @@ ssize_t foreign_symlink_upcall_store(struct kobject *kobj,
         * order, we may end up using the format provided by a different
         * upcall than the one set in ll_foreign_symlink_upcall
         */
-       sbi->ll_flags &= ~LL_SBI_FOREIGN_SYMLINK_UPCALL;
+       clear_bit(LL_SBI_FOREIGN_SYMLINK_UPCALL, sbi->ll_flags);
        up_write(&sbi->ll_foreign_symlink_sem);
 
        if (strcmp(new, "none")) {
@@ -752,7 +756,7 @@ ssize_t foreign_symlink_upcall_info_store(struct kobject *kobj,
        old_nb_items = sbi->ll_foreign_symlink_upcall_nb_items;
        sbi->ll_foreign_symlink_upcall_items = new_items;
        sbi->ll_foreign_symlink_upcall_nb_items = nb_items;
-       sbi->ll_flags |= LL_SBI_FOREIGN_SYMLINK_UPCALL;
+       set_bit(LL_SBI_FOREIGN_SYMLINK_UPCALL, sbi->ll_flags);
        up_write(&sbi->ll_foreign_symlink_sem);
 
        /* free old_items */
@@ -795,6 +799,33 @@ failed:
        RETURN(rc == 0 ? count : rc);
 }
 
+/* foreign fake-symlink version of ll_getattr() */
+#if defined(HAVE_USER_NAMESPACE_ARG)
+static int ll_foreign_symlink_getattr(struct mnt_idmap *map,
+                                     const struct path *path,
+                                     struct kstat *stat, u32 request_mask,
+                                     unsigned int flags)
+{
+       return ll_getattr_dentry(path->dentry, stat, request_mask, flags,
+                                true);
+}
+#elif defined(HAVE_INODEOPS_ENHANCED_GETATTR)
+static int ll_foreign_symlink_getattr(const struct path *path,
+                                     struct kstat *stat, u32 request_mask,
+                                     unsigned int flags)
+{
+       return ll_getattr_dentry(path->dentry, stat, request_mask, flags,
+                                true);
+}
+#else
+static int ll_foreign_symlink_getattr(struct vfsmount *mnt, struct dentry *de,
+                                     struct kstat *stat)
+{
+       return ll_getattr_dentry(de, stat, STATX_BASIC_STATS,
+                                AT_STATX_SYNC_AS_STAT, true);
+}
+#endif
+
 struct inode_operations ll_foreign_file_symlink_inode_operations = {
 #ifdef HAVE_IOP_GENERIC_READLINK
        .readlink       = generic_readlink,
@@ -838,20 +869,3 @@ struct inode_operations ll_foreign_dir_symlink_inode_operations = {
 #endif
        .listxattr      = ll_listxattr,
 };
-
-/* foreign fake-symlink version of ll_getattr() */
-#ifdef HAVE_INODEOPS_ENHANCED_GETATTR
-int ll_foreign_symlink_getattr(const struct path *path, struct kstat *stat,
-                              u32 request_mask, unsigned int flags)
-{
-       return ll_getattr_dentry(path->dentry, stat, request_mask, flags,
-                                true);
-}
-#else
-int ll_foreign_symlink_getattr(struct vfsmount *mnt, struct dentry *de,
-                              struct kstat *stat)
-{
-       return ll_getattr_dentry(de, stat, STATX_BASIC_STATS,
-                                AT_STATX_SYNC_AS_STAT, true);
-}
-#endif