From 763c07c431b2ae0a91f4caccf3a4ce86fbc67243 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Wed, 28 Feb 2018 11:36:52 +0800 Subject: [PATCH] LU-10607 osd-zfs: skip io stat for OI scrub It is unnecessary to stat io for OI scrub triggered request. On the other hand, the OI setup logic may read/write the OI scrub file. At that time, related lproc (including io stat) for such OSD is not initialized yet. So this patch skips io stat for OI scrub. Signed-off-by: Fan Yong Change-Id: I9498c1351c1875ac9aa46eed5189cb61a6d102ac Reviewed-on: https://review.whamcloud.com/31180 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/osd-zfs/osd_internal.h | 2 ++ lustre/osd-zfs/osd_io.c | 58 ++++++++++++++++++++++++++++++------------- lustre/osd-zfs/osd_scrub.c | 1 + 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 298207f..d21c0d0 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -97,6 +97,8 @@ #define OSD_GRANT_FOR_LOCAL_OIDS (2ULL << 20) /* 2MB for last_rcvd, ... */ +extern struct dt_body_operations osd_body_scrub_ops; + /** * Iterator's in-memory data structure for quota file. */ diff --git a/lustre/osd-zfs/osd_io.c b/lustre/osd-zfs/osd_io.c index ecbe5fe..ac7a9aa 100644 --- a/lustre/osd-zfs/osd_io.c +++ b/lustre/osd-zfs/osd_io.c @@ -106,15 +106,11 @@ static void record_end_io(struct osd_device *osd, int rw, } } -static ssize_t osd_read(const struct lu_env *env, struct dt_object *dt, - struct lu_buf *buf, loff_t *pos) +static ssize_t __osd_read(const struct lu_env *env, struct dt_object *dt, + struct lu_buf *buf, loff_t *pos, size_t *size) { struct osd_object *obj = osd_dt_obj(dt); - struct osd_device *osd = osd_obj2dev(obj); - int size = buf->lb_len; uint64_t old_size; - ktime_t start; - s64 delta_ms; int rc; LASSERT(dt_object_exists(dt)); @@ -124,28 +120,50 @@ static ssize_t osd_read(const struct lu_env *env, struct dt_object *dt, old_size = obj->oo_attr.la_size; read_unlock(&obj->oo_attr_lock); - if (*pos + size > old_size) { + if (*pos + *size > old_size) { if (old_size < *pos) return 0; - else - size = old_size - *pos; + + *size = old_size - *pos; } - start = ktime_get(); - record_start_io(osd, READ, 0); + rc = osd_dmu_read(osd_obj2dev(obj), obj->oo_dn, *pos, *size, + buf->lb_buf, DMU_READ_PREFETCH); + if (!rc) { + rc = *size; + *pos += *size; + } + + return rc; +} - rc = osd_dmu_read(osd, obj->oo_dn, *pos, size, buf->lb_buf, - DMU_READ_PREFETCH); +static ssize_t osd_read(const struct lu_env *env, struct dt_object *dt, + struct lu_buf *buf, loff_t *pos) +{ + struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt)); + size_t size = buf->lb_len; + ktime_t start; + s64 delta_ms; + int rc; + start = ktime_get(); + record_start_io(osd, READ, 0); + rc = __osd_read(env, dt, buf, pos, &size); delta_ms = ktime_ms_delta(ktime_get(), start); record_end_io(osd, READ, delta_ms, size, size >> PAGE_SHIFT); - if (rc == 0) { - rc = size; - *pos += size; - } + return rc; } +static inline ssize_t osd_read_no_record(const struct lu_env *env, + struct dt_object *dt, + struct lu_buf *buf, loff_t *pos) +{ + size_t size = buf->lb_len; + + return __osd_read(env, dt, buf, pos, &size); +} + static ssize_t osd_declare_write(const struct lu_env *env, struct dt_object *dt, const struct lu_buf *buf, loff_t pos, struct thandle *th) @@ -1049,3 +1067,9 @@ struct dt_body_operations osd_body_ops = { .dbo_punch = osd_punch, .dbo_ladvise = osd_ladvise, }; + +struct dt_body_operations osd_body_scrub_ops = { + .dbo_read = osd_read_no_record, + .dbo_declare_write = osd_declare_write, + .dbo_write = osd_write, +}; diff --git a/lustre/osd-zfs/osd_scrub.c b/lustre/osd-zfs/osd_scrub.c index 9a5c234..b8afa96 100644 --- a/lustre/osd-zfs/osd_scrub.c +++ b/lustre/osd-zfs/osd_scrub.c @@ -1448,6 +1448,7 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev) if (IS_ERR_OR_NULL(obj)) RETURN(obj ? PTR_ERR(obj) : -ENOENT); + obj->do_body_ops = &osd_body_scrub_ops; scrub->os_obj = obj; rc = scrub_file_load(env, scrub); if (rc == -ENOENT || rc == -EFAULT) { -- 1.8.3.1