Whamcloud - gitweb
LU-2941 llite: Delaying creation of client side proc entries.
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index 1eec9a6..43eb25a 100644 (file)
@@ -162,11 +162,6 @@ void ll_free_sbi(struct super_block *sb)
        EXIT;
 }
 
-static struct dentry_operations ll_d_root_ops = {
-        .d_compare = ll_dcompare,
-        .d_revalidate = ll_revalidate_nd,
-};
-
 static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                                     struct vfsmount *mnt)
 {
@@ -200,13 +195,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 RETURN(-ENOMEM);
         }
 
-        if (proc_lustre_fs_root) {
-                err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
-                                                  dt, md);
-                if (err < 0)
-                        CERROR("could not register mount in /proc/fs/lustre\n");
-        }
-
         /* indicate the features supported by this client */
         data->ocd_connect_flags = OBD_CONNECT_IBITS    | OBD_CONNECT_NODEVOH  |
                                   OBD_CONNECT_ATTRFID  |
@@ -219,7 +207,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                                  OBD_CONNECT_EINPROGRESS |
                                  OBD_CONNECT_JOBSTATS | OBD_CONNECT_LVB_TYPE |
                                  OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_PINGLESS |
-                                 OBD_CONNECT_MAX_EASIZE;
+                                 OBD_CONNECT_MAX_EASIZE |
+                                 OBD_CONNECT_FLOCK_DEAD;
 
         if (sbi->ll_flags & LL_SBI_SOM_PREVIEW)
                 data->ocd_connect_flags |= OBD_CONNECT_SOM;
@@ -589,13 +578,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                        ll_get_fsname(sb, NULL, 0));
                GOTO(out_root, err = -ENOMEM);
        }
-
 #ifdef HAVE_DCACHE_LOCK
-       sb->s_root->d_op = &ll_d_root_ops;
-#else
-       /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */
-       d_set_d_op(sb->s_root, &ll_d_root_ops);
-       sb->s_d_op = &ll_d_ops;
+       sb->s_root->d_op = &ll_d_ops;
 #endif
 
         sbi->ll_sdev_orig = sb->s_dev;
@@ -615,6 +599,15 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 OBD_FREE_PTR(data);
         if (osfs != NULL)
                 OBD_FREE_PTR(osfs);
+       if (proc_lustre_fs_root != NULL) {
+               err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
+                                                 dt, md);
+               if (err < 0) {
+                       CERROR("%s: could not register mount in lprocfs: "
+                              "rc = %d\n", ll_get_fsname(sb, NULL, 0), err);
+                       err = 0;
+               }
+       }
 
         RETURN(err);
 out_root:
@@ -637,7 +630,6 @@ out:
                 OBD_FREE_PTR(data);
         if (osfs != NULL)
                 OBD_FREE_PTR(osfs);
-        lprocfs_unregister_mountpoint(sbi);
         return err;
 }
 
@@ -1037,6 +1029,10 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
                GOTO(out_free, err);
 
         sb->s_bdi = &lsi->lsi_bdi;
+#ifndef HAVE_DCACHE_LOCK
+       /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */
+       sb->s_d_op = &ll_d_ops;
+#endif
 
         /* Generate a string unique to this super, in case some joker tries
            to mount the same fs at two mount points.
@@ -1094,7 +1090,7 @@ void lu_context_keys_dump(void);
 
 void ll_put_super(struct super_block *sb)
 {
-        struct config_llog_instance cfg;
+       struct config_llog_instance cfg, params_cfg;
         struct obd_device *obd;
         struct lustre_sb_info *lsi = s2lsi(sb);
         struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -1109,6 +1105,9 @@ void ll_put_super(struct super_block *sb)
         cfg.cfg_instance = sb;
         lustre_end_log(sb, profilenm, &cfg);
 
+       params_cfg.cfg_instance = sb;
+       lustre_end_log(sb, PARAMS_FILENAME, &params_cfg);
+
         if (sbi->ll_md_exp) {
                 obd = class_exp2obd(sbi->ll_md_exp);
                 if (obd)
@@ -1398,8 +1397,10 @@ static int ll_setattr_ost(struct inode *inode, struct iattr *attr)
  * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
  * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
  * at the same time.
+ *
+ * In case of HSMimport, we only set attr on MDS.
  */
-int ll_setattr_raw(struct dentry *dentry, struct iattr *attr)
+int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
 {
         struct inode *inode = dentry->d_inode;
         struct ll_inode_info *lli = ll_i2info(inode);
@@ -1410,9 +1411,10 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr)
         ENTRY;
 
        CDEBUG(D_VFSTRACE, "%s: setattr inode %p/fid:"DFID" from %llu to %llu, "
-               "valid %x\n", ll_get_fsname(inode->i_sb, NULL, 0), inode,
+               "valid %x, hsm_import %d\n",
+               ll_get_fsname(inode->i_sb, NULL, 0), inode,
                PFID(&lli->lli_fid), i_size_read(inode), attr->ia_size,
-               attr->ia_valid);
+               attr->ia_valid, hsm_import);
 
        if (attr->ia_valid & ATTR_SIZE) {
                 /* Check new size against VFS/VM file size limit and rlimit */
@@ -1505,20 +1507,20 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr)
                ccc_inode_lsm_put(inode, lsm);
        }
 
-       /* clear size attr for released file
+       /* if not in HSM import mode, clear size attr for released file
         * we clear the attribute send to MDT in op_data, not the original
         * received from caller in attr which is used later to
         * decide return code */
-       if (file_is_released && (attr->ia_valid & ATTR_SIZE))
+       if (file_is_released && (attr->ia_valid & ATTR_SIZE) && !hsm_import)
                op_data->op_attr.ia_valid &= ~ATTR_SIZE;
 
         rc = ll_md_setattr(dentry, op_data, &mod);
         if (rc)
                 GOTO(out, rc);
 
-       /* truncate failed, others succeed */
+       /* truncate failed (only when non HSM import), others succeed */
        if (file_is_released) {
-               if (attr->ia_valid & ATTR_SIZE)
+               if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
                        GOTO(out, rc = -ENODATA);
                else
                        GOTO(out, rc = 0);
@@ -1559,7 +1561,7 @@ out:
        if (!S_ISDIR(inode->i_mode)) {
                up_write(&lli->lli_trunc_sem);
                mutex_lock(&inode->i_mutex);
-               if (attr->ia_valid & ATTR_SIZE)
+               if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
                        inode_dio_wait(inode);
        }
 
@@ -1571,30 +1573,30 @@ out:
 
 int ll_setattr(struct dentry *de, struct iattr *attr)
 {
-        int mode = de->d_inode->i_mode;
-
-        if ((attr->ia_valid & (ATTR_CTIME|ATTR_SIZE|ATTR_MODE)) ==
-                              (ATTR_CTIME|ATTR_SIZE|ATTR_MODE))
-                attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE;
-
-        if (((attr->ia_valid & (ATTR_MODE|ATTR_FORCE|ATTR_SIZE)) ==
-                               (ATTR_SIZE|ATTR_MODE)) &&
-            (((mode & S_ISUID) && !(attr->ia_mode & S_ISUID)) ||
-             (((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) &&
-              !(attr->ia_mode & S_ISGID))))
-                attr->ia_valid |= ATTR_FORCE;
-
-        if ((mode & S_ISUID) &&
-            !(attr->ia_mode & S_ISUID) &&
-            !(attr->ia_valid & ATTR_KILL_SUID))
-                attr->ia_valid |= ATTR_KILL_SUID;
-
-        if (((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) &&
-            !(attr->ia_mode & S_ISGID) &&
-            !(attr->ia_valid & ATTR_KILL_SGID))
-                attr->ia_valid |= ATTR_KILL_SGID;
-
-        return ll_setattr_raw(de, attr);
+       int mode = de->d_inode->i_mode;
+
+       if ((attr->ia_valid & (ATTR_CTIME|ATTR_SIZE|ATTR_MODE)) ==
+                             (ATTR_CTIME|ATTR_SIZE|ATTR_MODE))
+               attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE;
+
+       if (((attr->ia_valid & (ATTR_MODE|ATTR_FORCE|ATTR_SIZE)) ==
+                              (ATTR_SIZE|ATTR_MODE)) &&
+           (((mode & S_ISUID) && !(attr->ia_mode & S_ISUID)) ||
+            (((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) &&
+             !(attr->ia_mode & S_ISGID))))
+               attr->ia_valid |= ATTR_FORCE;
+
+       if ((mode & S_ISUID) &&
+           !(attr->ia_mode & S_ISUID) &&
+           !(attr->ia_valid & ATTR_KILL_SUID))
+               attr->ia_valid |= ATTR_KILL_SUID;
+
+       if (((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) &&
+           !(attr->ia_mode & S_ISGID) &&
+           !(attr->ia_valid & ATTR_KILL_SGID))
+               attr->ia_valid |= ATTR_KILL_SGID;
+
+       return ll_setattr_raw(de, attr, false);
 }
 
 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,