From: Nathaniel Clark Date: Thu, 25 Jun 2015 21:24:34 +0000 (-0400) Subject: LU-6767 osd-zfs: Track readonly status of ZFS X-Git-Tag: 2.7.65~80 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f045898e125128226631b8d949a61420332d9237 LU-6767 osd-zfs: Track readonly status of ZFS Return READONLY from osd_statfs() if underlying ZFS has been set to READONLY, or if osd_ro() has been called. This adds a callback for ZFS_PROP_READONLY for when it's changed. Signed-off-by: Nathaniel Clark Change-Id: Ib7f35925904b1d93f9a457936585e9783635c849 Reviewed-on: http://review.whamcloud.com/15400 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index 6fc37d5..4f78957 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -502,11 +502,9 @@ static int osd_objset_statfs(struct osd_device *osd, struct obd_statfs *osfs) 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; - */ + if (!spa_writeable(dmu_objset_spa(os)) || + osd->od_dev_set_rdonly || osd->od_prop_rdonly) + osfs->os_state |= OS_STATE_READONLY; return 0; } @@ -631,7 +629,7 @@ static int osd_ro(const struct lu_env *env, struct dt_device *d) CERROR("%s: *** setting device %s read-only ***\n", osd->od_svname, LUSTRE_OSD_ZFS_NAME); - osd->od_rdonly = 1; + osd->od_dev_set_rdonly = 1; spa_freeze(dmu_objset_spa(osd->od_os)); RETURN(0); @@ -743,6 +741,13 @@ static void osd_recordsize_changed_cb(void *arg, uint64_t newval) osd->od_max_blksz = newval; } +static void osd_readonly_changed_cb(void *arg, uint64_t newval) +{ + struct osd_device *osd = arg; + + osd->od_prop_rdonly = !!newval; +} + /* * This function unregisters all registered callbacks. It's harmless to * unregister callbacks that were never registered so it is used to safely @@ -756,6 +761,8 @@ static void osd_objset_unregister_callbacks(struct osd_device *o) osd_xattr_changed_cb, o); (void) dsl_prop_unregister(ds, zfs_prop_to_name(ZFS_PROP_RECORDSIZE), osd_recordsize_changed_cb, o); + (void) dsl_prop_unregister(ds, zfs_prop_to_name(ZFS_PROP_READONLY), + osd_readonly_changed_cb, o); if (o->arc_prune_cb != NULL) { arc_remove_prune_callback(o->arc_prune_cb); @@ -787,6 +794,11 @@ static int osd_objset_register_callbacks(struct osd_device *o) if (rc) GOTO(err, rc); + rc = -dsl_prop_register(ds, zfs_prop_to_name(ZFS_PROP_READONLY), + osd_readonly_changed_cb, o); + if (rc) + GOTO(err, rc); + o->arc_prune_cb = arc_add_prune_callback(arc_prune_func, o); err: dsl_pool_config_exit(dp, FTAG); diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index d532e52..62543f8 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -262,7 +262,8 @@ struct osd_device { unsigned int od_oi_count; struct osd_seq_list od_seq_list; - unsigned int od_rdonly:1, + unsigned int od_dev_set_rdonly:1, /**< osd_ro() called */ + od_prop_rdonly:1, /**< ZFS property readonly */ od_xattr_in_sa:1, od_quota_iused_est:1, od_is_ost:1,