Whamcloud - gitweb
LU-9679 lustre: use LIST_HEAD() for local lists.
[fs/lustre-release.git] / lustre / osd-zfs / osd_handler.c
index c7d890b..10ef06c 100644 (file)
@@ -147,8 +147,6 @@ static void osd_trans_commit_cb(void *cb_data, int error)
                                osd_dt_dev(th->th_dev)->od_svname, th, error);
        }
 
-       dt_txn_hook_commit(th);
-
        /* call per-transaction callbacks if any */
        list_for_each_entry_safe(dcb, tmp, &oh->ot_dcb_list, dcb_linkage) {
                LASSERTF(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC,
@@ -282,13 +280,12 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
        struct osd_device       *osd = osd_dt_dev(th->th_dev);
        bool                     sync = (th->th_sync != 0);
        struct osd_thandle      *oh;
-       struct list_head         unlinked;
+       LIST_HEAD(unlinked);
        uint64_t                 txg;
        int                      rc;
        ENTRY;
 
        oh = container_of0(th, struct osd_thandle, ot_super);
-       INIT_LIST_HEAD(&unlinked);
        list_splice_init(&oh->ot_unlinked_list, &unlinked);
 
        osd_oti_get(env)->oti_ins_cache_depth--;
@@ -413,8 +410,8 @@ uint64_t osd_objs_count_estimate(uint64_t usedbytes, uint64_t usedobjs,
         * gradually disappears as the number of real dnodes grows.  It also
         * avoids the need to check for divide-by-zero computing dn_per_block.
         */
-       CLASSERT(OSD_DNODE_MIN_BLKSHIFT > 0);
-       CLASSERT(OSD_DNODE_EST_BLKSHIFT > 0);
+       BUILD_BUG_ON(OSD_DNODE_MIN_BLKSHIFT <= 0);
+       BUILD_BUG_ON(OSD_DNODE_EST_BLKSHIFT <= 0);
 
        est_usedblocks = ((OSD_DNODE_EST_COUNT << OSD_DNODE_EST_BLKSHIFT) +
                          usedbytes) >> est_maxblockshift;
@@ -515,7 +512,7 @@ static int osd_objset_statfs(struct osd_device *osd, struct obd_statfs *osfs)
         * 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);
+       BUILD_BUG_ON(OSD_STATFS_RESERVED_SIZE <= 0);
        reserved = OSD_STATFS_RESERVED_SIZE >> bshift;
        if (likely(osfs->os_blocks >= reserved << OSD_STATFS_RESERVED_SHIFT))
                reserved = osfs->os_blocks >> OSD_STATFS_RESERVED_SHIFT;
@@ -554,18 +551,25 @@ static int osd_objset_statfs(struct osd_device *osd, struct obd_statfs *osfs)
  * Concurrency: shouldn't matter.
  */
 int osd_statfs(const struct lu_env *env, struct dt_device *d,
-              struct obd_statfs *osfs)
+              struct obd_statfs *osfs, struct obd_statfs_info *info)
 {
-       int                rc;
+       struct osd_device *osd = osd_dt_dev(d);
+       int               rc;
        ENTRY;
 
-       rc = osd_objset_statfs(osd_dt_dev(d), osfs);
+       rc = osd_objset_statfs(osd, osfs);
        if (unlikely(rc != 0))
                RETURN(rc);
 
        osfs->os_bavail -= min_t(u64,
                                 OSD_GRANT_FOR_LOCAL_OIDS / osfs->os_bsize,
                                 osfs->os_bavail);
+
+       /* ZFS does not support reporting nonrotional status yet, so return
+        * flag only if user has set nonrotational.
+        */
+       osfs->os_state |= osd->od_nonrotational ? OS_STATE_NONROT : 0;
+
        RETURN(0);
 }
 
@@ -580,7 +584,7 @@ static int osd_blk_insert_cost(struct osd_device *osd)
 
        /* nr_blkptrshift is the log2 of the number of block pointers that can
         * be stored in an indirect block */
-       CLASSERT(DN_MAX_INDBLKSHIFT > SPA_BLKPTRSHIFT);
+       BUILD_BUG_ON(DN_MAX_INDBLKSHIFT <= SPA_BLKPTRSHIFT);
        nr_blkptrshift = DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT;
 
        /* max_blockshift / nr_blkptrshift is thus the maximum depth of the
@@ -610,7 +614,8 @@ static void osd_conf_get(const struct lu_env *env,
        param->ddp_mntopts      = MNTOPT_USERXATTR;
        if (osd->od_posix_acl)
                param->ddp_mntopts |= MNTOPT_ACL;
-       param->ddp_max_ea_size  = DXATTR_MAX_ENTRY_SIZE;
+       /* Previously DXATTR_MAX_ENTRY_SIZE */
+       param->ddp_max_ea_size  = OBD_MAX_EA_SIZE;
 
        /* for maxbytes, report same value as ZPL */
        param->ddp_maxbytes     = MAX_LFS_FILESIZE;
@@ -906,7 +911,7 @@ static int osd_objset_open(struct osd_device *o)
 
        rc = -osd_dmu_objset_own(o->od_mntdev, DMU_OST_ZFS,
                             o->od_dt_dev.dd_rdonly ? B_TRUE : B_FALSE,
-                            B_FALSE, o, &o->od_os);
+                            B_TRUE, o, &o->od_os);
 
        if (rc) {
                CERROR("%s: can't open %s\n", o->od_svname, o->od_mntdev);
@@ -971,7 +976,7 @@ static int osd_objset_open(struct osd_device *o)
 
 out:
        if (rc != 0 && o->od_os != NULL) {
-               osd_dmu_objset_disown(o->od_os, B_FALSE, o);
+               osd_dmu_objset_disown(o->od_os, B_TRUE, o);
                o->od_os = NULL;
        }
 
@@ -1204,7 +1209,7 @@ static int osd_mount(const struct lu_env *env,
        osd_unlinked_drain(env, o);
 err:
        if (rc && o->od_os) {
-               osd_dmu_objset_disown(o->od_os, B_FALSE, o);
+               osd_dmu_objset_disown(o->od_os, B_TRUE, o);
                o->od_os = NULL;
        }
 
@@ -1251,7 +1256,7 @@ static void osd_umount(const struct lu_env *env, struct osd_device *o)
                        txg_wait_synced(dmu_objset_pool(o->od_os), 0ULL);
 
                /* close the object set */
-               osd_dmu_objset_disown(o->od_os, B_FALSE, o);
+               osd_dmu_objset_disown(o->od_os, B_TRUE, o);
                o->od_os = NULL;
        }
 
@@ -1276,6 +1281,11 @@ static int osd_device_init0(const struct lu_env *env,
        INIT_LIST_HEAD(&o->od_ios_list);
        o->od_auto_scrub_interval = AS_DEFAULT;
 
+       /* ZFS does not support reporting nonrotional status yet, so this flag
+        * is only set if explicitly set by the user.
+        */
+       o->od_nonrotational = 0;
+
 out:
        RETURN(rc);
 }
@@ -1388,10 +1398,11 @@ static int osd_device_init(const struct lu_env *env, struct lu_device *d,
 static int osd_process_config(const struct lu_env *env,
                              struct lu_device *d, struct lustre_cfg *cfg)
 {
-       struct osd_device       *o = osd_dev(d);
-       int                     rc;
-       ENTRY;
+       struct osd_device *o = osd_dev(d);
+       ssize_t count;
+       int rc;
 
+       ENTRY;
        switch(cfg->lcfg_command) {
        case LCFG_SETUP:
                rc = osd_mount(env, o, cfg);
@@ -1404,15 +1415,12 @@ static int osd_process_config(const struct lu_env *env,
                break;
        case LCFG_PARAM: {
                LASSERT(&o->od_dt_dev);
-               rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars,
-                                             cfg, &o->od_dt_dev);
-               if (rc > 0 || rc == -ENOSYS) {
-                       rc = class_process_proc_param(PARAM_OST,
-                                                     lprocfs_osd_obd_vars,
-                                                     cfg, &o->od_dt_dev);
-                       if (rc > 0)
-                               rc = 0;
-               }
+               count  = class_modify_config(cfg, PARAM_OSD,
+                                            &o->od_dt_dev.dd_kobj);
+               if (count < 0)
+                       count = class_modify_config(cfg, PARAM_OST,
+                                                   &o->od_dt_dev.dd_kobj);
+               rc = count > 0 ? 0 : count;
                break;
        }
        case LCFG_PRE_CLEANUP:
@@ -1605,7 +1613,7 @@ static struct lu_device_type osd_device_type = {
 };
 
 
-static struct obd_ops osd_obd_device_ops = {
+static const struct obd_ops osd_obd_device_ops = {
        .o_owner       = THIS_MODULE,
        .o_connect      = osd_obd_connect,
        .o_disconnect   = osd_obd_disconnect,