LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com> To: linux-kernel@vger.kernel.org, Dave Kleikamp <dave.kleikamp@oracle.com> Cc: Jens Axboe <axboe@kernel.dk>, Zach Brown <zab@zabbo.net>, Christoph Hellwig <hch@infradead.org>, Maxim Patlasov <mpatlasov@parallels.com>, Andrew Morton <akpm@linux-foundation.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Benjamin LaHaise <bcrl@kvack.org>, Ming Lei <ming.lei@canonical.com> Subject: [PATCH v2 3/4] block: loop: introduce 'use_aio' sysfs file Date: Tue, 13 Jan 2015 23:44:47 +0800 [thread overview] Message-ID: <1421163888-21452-4-git-send-email-ming.lei@canonical.com> (raw) In-Reply-To: <1421163888-21452-1-git-send-email-ming.lei@canonical.com> So that users can control if kernel aio is used to submit I/O. Signed-off-by: Ming Lei <ming.lei@canonical.com> --- drivers/block/loop.c | 33 +++++++++++++++++++++++++++++++++ drivers/block/loop.h | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index d1f168b..47af456 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -659,6 +659,38 @@ static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf) return sprintf(buf, "%s\n", partscan ? "1" : "0"); } +static ssize_t loop_attr_do_show_use_aio(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct gendisk *disk = dev_to_disk(dev); + struct loop_device *lo = disk->private_data; + + return sprintf(buf, "%s\n", lo->use_aio ? "1" : "0"); +} + +ssize_t loop_attr_do_store_use_aio(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + struct gendisk *disk = dev_to_disk(dev); + struct loop_device *lo = disk->private_data; + int err; + unsigned long v; + + err = kstrtoul(buf, 10, &v); + if (err < 0) + return err; + if (v) + lo->use_aio = true; + else + lo->use_aio = false; + return count; +} + +static struct device_attribute loop_attr_use_aio = + __ATTR(use_aio, S_IRUGO | S_IWUSR, loop_attr_do_show_use_aio, + loop_attr_do_store_use_aio); + LOOP_ATTR_RO(backing_file); LOOP_ATTR_RO(offset); LOOP_ATTR_RO(sizelimit); @@ -671,6 +703,7 @@ static struct attribute *loop_attrs[] = { &loop_attr_sizelimit.attr, &loop_attr_autoclear.attr, &loop_attr_partscan.attr, + &loop_attr_use_aio.attr, NULL, }; diff --git a/drivers/block/loop.h b/drivers/block/loop.h index 301c27f..15049e9 100644 --- a/drivers/block/loop.h +++ b/drivers/block/loop.h @@ -57,6 +57,7 @@ struct loop_device { struct list_head write_cmd_head; struct work_struct write_work; bool write_started; + bool use_aio; int lo_state; struct mutex lo_ctl_mutex; -- 1.7.9.5
next prev parent reply other threads:[~2015-01-13 15:45 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-01-13 15:44 [PATCH v2 0/4] block & aio: improve loop with kernel aio Ming Lei 2015-01-13 15:44 ` [PATCH v2 1/4] aio: add aio_kernel_() interface Ming Lei 2015-01-25 13:31 ` Christoph Hellwig 2015-01-26 16:18 ` Ming Lei 2015-01-26 17:00 ` Christoph Hellwig 2015-01-27 13:57 ` Ming Lei 2015-01-27 17:59 ` Christoph Hellwig 2015-01-13 15:44 ` [PATCH v2 2/4] fd/direct-io: introduce should_dirty for kernel aio Ming Lei 2015-01-25 13:34 ` Christoph Hellwig 2015-01-27 16:05 ` Ming Lei 2015-01-13 15:44 ` Ming Lei [this message] 2015-01-25 13:35 ` [PATCH v2 3/4] block: loop: introduce 'use_aio' sysfs file Christoph Hellwig 2015-01-27 5:26 ` Ming Lei 2015-01-26 17:57 ` Jeff Moyer 2015-01-13 15:44 ` [PATCH v2 4/4] block: loop: support to submit I/O via kernel aio based Ming Lei 2015-01-25 13:40 ` Christoph Hellwig 2015-03-18 18:28 ` Maxim Patlasov 2015-03-19 2:57 ` Ming Lei 2015-03-19 16:37 ` Maxim Patlasov 2015-03-20 5:27 ` Ming Lei 2015-01-13 16:23 ` [PATCH v2 0/4] block & aio: improve loop with kernel aio Christoph Hellwig 2015-01-14 10:17 ` Ming Lei
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1421163888-21452-4-git-send-email-ming.lei@canonical.com \ --to=ming.lei@canonical.com \ --cc=akpm@linux-foundation.org \ --cc=axboe@kernel.dk \ --cc=bcrl@kvack.org \ --cc=dave.kleikamp@oracle.com \ --cc=hch@infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mpatlasov@parallels.com \ --cc=viro@zeniv.linux.org.uk \ --cc=zab@zabbo.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).