From: Mike Snitzer <snitzer@redhat.com>
To: Pankaj Gupta <pagupta@redhat.com>
Cc: dm-devel@redhat.com, linux-nvdimm@lists.01.org,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org, kvm@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-acpi@vger.kernel.org,
qemu-devel@nongnu.org, linux-ext4@vger.kernel.org,
linux-xfs@vger.kernel.org, dan.j.williams@intel.com,
zwisler@kernel.org, vishal.l.verma@intel.com,
dave.jiang@intel.com, mst@redhat.com, jasowang@redhat.com,
willy@infradead.org, rjw@rjwysocki.net, hch@infradead.org,
lenb@kernel.org, jack@suse.cz, tytso@mit.edu,
adilger.kernel@dilger.ca, darrick.wong@oracle.com,
lcapitulino@redhat.com, kwolf@redhat.com, imammedo@redhat.com,
jmoyer@redhat.com, nilal@redhat.com, riel@surriel.com,
stefanha@redhat.com, aarcange@redhat.com, david@redhat.com,
david@fromorbit.com, cohuck@redhat.com,
xiaoguangrong.eric@gmail.com, pbonzini@redhat.com,
yuval.shaia@oracle.com, kilobyte@angband.pl, jstaron@google.com,
rdunlap@infradead.org
Subject: Re: [PATCH v11 4/7] dm: enable synchronous dax
Date: Mon, 10 Jun 2019 15:28:03 -0400 [thread overview]
Message-ID: <20190610192803.GA29002@redhat.com> (raw)
In-Reply-To: <20190610090730.8589-5-pagupta@redhat.com>
On Mon, Jun 10 2019 at 5:07am -0400,
Pankaj Gupta <pagupta@redhat.com> wrote:
> This patch sets dax device 'DAXDEV_SYNC' flag if all the target
> devices of device mapper support synchrononous DAX. If device
> mapper consists of both synchronous and asynchronous dax devices,
> we don't set 'DAXDEV_SYNC' flag.
>
> Signed-off-by: Pankaj Gupta <pagupta@redhat.com>
> ---
> drivers/md/dm-table.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 350cf0451456..c5160d846fe6 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -890,10 +890,17 @@ static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
> start, len);
> }
>
> +static int device_synchronous(struct dm_target *ti, struct dm_dev *dev,
> + sector_t start, sector_t len, void *data)
> +{
> + return dax_synchronous(dev->dax_dev);
> +}
> +
> bool dm_table_supports_dax(struct dm_table *t, int blocksize)
> {
> struct dm_target *ti;
> unsigned i;
> + bool dax_sync = true;
>
> /* Ensure that all targets support DAX. */
> for (i = 0; i < dm_table_get_num_targets(t); i++) {
> @@ -906,7 +913,14 @@ bool dm_table_supports_dax(struct dm_table *t, int blocksize)
> !ti->type->iterate_devices(ti, device_supports_dax,
> &blocksize))
> return false;
> +
> + /* Check devices support synchronous DAX */
> + if (dax_sync &&
> + !ti->type->iterate_devices(ti, device_synchronous, NULL))
> + dax_sync = false;
> }
> + if (dax_sync)
> + set_dax_synchronous(t->md->dax_dev);
>
> return true;
> }
> --
> 2.20.1
>
dm_table_supports_dax() is called multiple times (from
dm_table_set_restrictions and dm_table_determine_type). It is strange
to have a getter have a side-effect of being a setter too. Overloading
like this could get you in trouble in the future.
Are you certain this is what you want?
Or would it be better to refactor dm_table_supports_dax() to take an
iterate_devices_fn arg and have callers pass the appropriate function?
Then have dm_table_set_restrictions() caller do:
if (dm_table_supports_dax(t, device_synchronous, NULL))
set_dax_synchronous(t->md->dax_dev);
(NULL arg implies dm_table_supports_dax() refactoring would take a int
*data pointer rather than int type).
Mike
next prev parent reply other threads:[~2019-06-10 19:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 9:07 [PATCH v11 0/7] virtio pmem driver Pankaj Gupta
2019-06-10 9:07 ` [PATCH v11 1/7] libnvdimm: nd_region flush callback support Pankaj Gupta
2019-06-10 9:07 ` [PATCH v11 2/7] virtio-pmem: Add virtio pmem driver Pankaj Gupta
2019-06-10 9:07 ` [PATCH v11 3/7] libnvdimm: add dax_dev sync flag Pankaj Gupta
2019-06-10 9:07 ` [PATCH v11 4/7] dm: enable synchronous dax Pankaj Gupta
2019-06-10 19:28 ` Mike Snitzer [this message]
2019-06-11 13:10 ` [Qemu-devel] " Pankaj Gupta
2019-06-11 15:04 ` Mike Snitzer
2019-06-11 16:04 ` [Qemu-devel] " Pankaj Gupta
2019-06-10 9:07 ` [PATCH v11 5/7] dax: check synchronous mapping is supported Pankaj Gupta
2019-06-10 9:07 ` [PATCH v11 6/7] ext4: disable map_sync for async flush Pankaj Gupta
2019-06-10 9:07 ` [PATCH v11 7/7] xfs: " Pankaj Gupta
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=20190610192803.GA29002@redhat.com \
--to=snitzer@redhat.com \
--cc=aarcange@redhat.com \
--cc=adilger.kernel@dilger.ca \
--cc=cohuck@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=darrick.wong@oracle.com \
--cc=dave.jiang@intel.com \
--cc=david@fromorbit.com \
--cc=david@redhat.com \
--cc=dm-devel@redhat.com \
--cc=hch@infradead.org \
--cc=imammedo@redhat.com \
--cc=jack@suse.cz \
--cc=jasowang@redhat.com \
--cc=jmoyer@redhat.com \
--cc=jstaron@google.com \
--cc=kilobyte@angband.pl \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mst@redhat.com \
--cc=nilal@redhat.com \
--cc=pagupta@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rdunlap@infradead.org \
--cc=riel@surriel.com \
--cc=rjw@rjwysocki.net \
--cc=stefanha@redhat.com \
--cc=tytso@mit.edu \
--cc=virtualization@lists.linux-foundation.org \
--cc=vishal.l.verma@intel.com \
--cc=willy@infradead.org \
--cc=xiaoguangrong.eric@gmail.com \
--cc=yuval.shaia@oracle.com \
--cc=zwisler@kernel.org \
/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: link
Be 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).