Whamcloud - gitweb
LU-6378 osd-ldiskfs: unlock inode before attr_init
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_handler.c
index e2d7e68..2105a26 100644 (file)
 #define DEBUG_SUBSYSTEM S_OSD
 
 #include <linux/module.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 
 /* LUSTRE_VERSION_CODE */
 #include <lustre_ver.h>
@@ -959,7 +963,7 @@ static void osd_trans_commit_cb(struct super_block *sb,
 
         lu_context_exit(&th->th_ctx);
         lu_context_fini(&th->th_ctx);
-       thandle_put(th);
+       OBD_FREE_PTR(oh);
 }
 
 static struct thandle *osd_trans_create(const struct lu_env *env,
@@ -984,8 +988,6 @@ static struct thandle *osd_trans_create(const struct lu_env *env,
                th->th_result = 0;
                th->th_tags = LCT_TX_HANDLE;
                oh->ot_credits = 0;
-               atomic_set(&th->th_refc, 1);
-               th->th_alloc_size = sizeof(*oh);
                INIT_LIST_HEAD(&oh->ot_dcb_list);
                osd_th_alloced(oh);
 
@@ -1169,7 +1171,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
                        CERROR("%s: failed to stop transaction: rc = %d\n",
                               osd_name(osd), rc);
        } else {
-               thandle_put(&oh->ot_super);
+               OBD_FREE_PTR(oh);
        }
 
        /* inform the quota slave device that the transaction is stopping */
@@ -2199,17 +2201,19 @@ static int __osd_object_create(struct osd_thread_info *info,
 
        result = osd_create_type_f(dof->dof_type)(info, obj, attr, hint, dof,
                                                  th);
-       if (result == 0) {
-               osd_attr_init(info, obj, attr, dof);
-               osd_object_init0(obj);
-       }
-
-       if (obj->oo_inode != NULL) {
+       if (likely(obj->oo_inode != NULL)) {
                LASSERT(obj->oo_inode->i_state & I_NEW);
 
+               /* Unlock the inode before attr initialization to avoid
+                * unnecessary dqget operations. LU-6378 */
                unlock_new_inode(obj->oo_inode);
        }
 
+       if (likely(result == 0)) {
+               osd_attr_init(info, obj, attr, dof);
+               osd_object_init0(obj);
+       }
+
        /* restore previous umask value */
        current->fs->umask = umask;
 
@@ -6251,6 +6255,8 @@ static void __exit osd_mod_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Object Storage Device ("LUSTRE_OSD_LDISKFS_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(osd, "0.1.0", osd_mod_init, osd_mod_exit);
+module_init(osd_mod_init);
+module_exit(osd_mod_exit);