Commit 29091a80 authored by Federico Vaga's avatar Federico Vaga Committed by Alessandro Rubini

zattr_show: check if zattr->s_op are present

If a zio object declares a set of read only attributes and it doesn't
need s_op->info_get(), it can avoid the s_op assignment, so zattr_show
now checks if s_op is defined before calling it.
Signed-off-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent fdb09d3e
......@@ -698,6 +698,9 @@ static ssize_t zattr_show(struct kobject *kobj, struct attribute *attr,
return sprintf(buf, "%d\n",
!((*__get_flag(to_zio_head(kobj))) & ZIO_DISABLED));
/* only read attributes can avoid s_op declaration */
if (!zattr->s_op)
goto out;
if (zattr->s_op->info_get) {
lock = __get_spinlock(to_zio_head(kobj));
spin_lock(lock);
......@@ -706,6 +709,7 @@ static ssize_t zattr_show(struct kobject *kobj, struct attribute *attr,
if (err)
return err;
}
out:
len = sprintf(buf, "%i\n", zattr->value);
return len;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment