Whamcloud - gitweb
LU-7345 obdclass: annotate locks in __local_file_create
[fs/lustre-release.git] / lustre / osd-zfs / osd_handler.c
index c87cc00..556c875 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -173,10 +173,15 @@ static void osd_trans_commit_cb(void *cb_data, int error)
 
 static int osd_trans_cb_add(struct thandle *th, struct dt_txn_commit_cb *dcb)
 {
-       struct osd_thandle *oh;
+       struct osd_thandle *oh = container_of0(th, struct osd_thandle,
+                                              ot_super);
 
-       oh = container_of0(th, struct osd_thandle, ot_super);
-       list_add(&dcb->dcb_linkage, &oh->ot_dcb_list);
+       LASSERT(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC);
+       LASSERT(&dcb->dcb_func != NULL);
+       if (dcb->dcb_flags & DCB_TRANS_STOP)
+               list_add(&dcb->dcb_linkage, &oh->ot_stop_dcb_list);
+       else
+               list_add(&dcb->dcb_linkage, &oh->ot_dcb_list);
 
        return 0;
 }
@@ -247,6 +252,22 @@ static void osd_unlinked_list_emptify(struct osd_device *osd,
        }
 }
 
+static void osd_trans_stop_cb(struct osd_thandle *oth, int result)
+{
+       struct dt_txn_commit_cb *dcb;
+       struct dt_txn_commit_cb *tmp;
+
+       /* call per-transaction stop callbacks if any */
+       list_for_each_entry_safe(dcb, tmp, &oth->ot_stop_dcb_list,
+                                dcb_linkage) {
+               LASSERTF(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC,
+                        "commit callback entry: magic=%x name='%s'\n",
+                        dcb->dcb_magic, dcb->dcb_name);
+               list_del_init(&dcb->dcb_linkage);
+               dcb->dcb_func(NULL, &oth->ot_super, dcb, result);
+       }
+}
+
 /*
  * Concurrency: shouldn't matter.
  */
@@ -292,6 +313,8 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
                CDEBUG(D_OTHER, "%s: transaction hook failed: rc = %d\n",
                       osd->od_svname, rc);
 
+       osd_trans_stop_cb(oh, rc);
+
        LASSERT(oh->ot_tx);
        txg = oh->ot_tx->tx_txg;
 
@@ -330,6 +353,7 @@ static struct thandle *osd_trans_create(const struct lu_env *env,
 
        oh->ot_tx = tx;
        INIT_LIST_HEAD(&oh->ot_dcb_list);
+       INIT_LIST_HEAD(&oh->ot_stop_dcb_list);
        INIT_LIST_HEAD(&oh->ot_unlinked_list);
        INIT_LIST_HEAD(&oh->ot_sa_list);
        sema_init(&oh->ot_sa_lock, 1);
@@ -417,6 +441,11 @@ static int osd_objset_statfs(struct osd_device *osd, struct obd_statfs *osfs)
 
        dmu_objset_space(os, &refdbytes, &availbytes, &usedobjs, &availobjs);
 
+       memset(osfs, 0, sizeof(*osfs));
+
+       /* We're a zfs filesystem. */
+       osfs->os_type = UBERBLOCK_MAGIC;
+
        /*
         * ZFS allows multiple block sizes.  For statfs, Linux makes no
         * proper distinction between bsize and frsize.  For calculations
@@ -441,7 +470,7 @@ static int osd_objset_statfs(struct osd_device *osd, struct obd_statfs *osfs)
         * Rather than report this via os_bavail (which makes users unhappy if
         * they can't fill the filesystem 100%), reduce os_blocks as well.
         *
-        * Reserve 0.78% of total space, at least 4MB for small filesystems,
+        * Reserve 0.78% of total space, at least 16MB for small filesystems,
         * for internal files to be created/unlinked when space is tight.
         */
        CLASSERT(OSD_STATFS_RESERVED_SIZE > 0);
@@ -470,18 +499,15 @@ static int osd_objset_statfs(struct osd_device *osd, struct obd_statfs *osfs)
        /* ZFS XXX: fill in backing dataset FSID/UUID
           memcpy(osfs->os_fsid, .... );*/
 
-       /* We're a zfs filesystem. */
-       osfs->os_type = UBERBLOCK_MAGIC;
+       osfs->os_namelen = MAXNAMELEN;
+       osfs->os_maxbytes = OBD_OBJECT_EOF;
 
        /* ZFS XXX: fill in appropriate OS_STATE_{DEGRADED,READONLY} flags
           osfs->os_state = vf_to_stf(vfsp->vfs_flag);
           if (sb->s_flags & MS_RDONLY)
-          osfs->os_state = OS_STATE_READONLY;
+          osfs->os_state |= OS_STATE_READONLY;
         */
 
-       osfs->os_namelen = MAXNAMELEN;
-       osfs->os_maxbytes = OBD_OBJECT_EOF;
-
        return 0;
 }
 
@@ -965,10 +991,6 @@ static int osd_mount(const struct lu_env *env,
        if (rc)
                GOTO(err, rc);
 
-       rc = osd_convert_root_to_new_seq(env, o);
-       if (rc)
-               GOTO(err, rc);
-
        /* Use our own ZAP for inode accounting by default, this can be changed
         * via procfs to estimate the inode usage from the block usage */
        o->od_quota_iused_est = 0;
@@ -1364,7 +1386,7 @@ CFS_MODULE_PARM(osd_oi_count, "i", int, 0444,
                "Number of Object Index containers to be created, "
                "it's only valid for new filesystem.");
 
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
+MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Object Storage Device ("LUSTRE_OSD_ZFS_NAME")");
 MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");