All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Christoph Hellwig <hch@infradead.org>,
	Zhiqiang Liu <liuzhiqiang26@huawei.com>
Cc: lixiaokeng <lixiaokeng@huawei.com>,
	"wubo \(T\)" <wubo40@huawei.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	linux-kernel@vger.kernel.org, linfeilong <linfeilong@huawei.com>,
	dm-devel@redhat.com, agk@redhat.com
Subject: Re: [dm-devel] md/dm-mpath: check whether all pgpaths have same uuid in multipath_ctr()
Date: Mon, 22 Mar 2021 10:22:07 -0400	[thread overview]
Message-ID: <20210322142207.GB30698@redhat.com> (raw)
In-Reply-To: <20210322081155.GE1946905@infradead.org>

On Mon, Mar 22 2021 at  4:11am -0400,
Christoph Hellwig <hch@infradead.org> wrote:

> On Sat, Mar 20, 2021 at 03:19:23PM +0800, Zhiqiang Liu wrote:
> > From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> > 
> > When we make IO stress test on multipath device, there will
> > be a metadata err because of wrong path. In the test, we
> > concurrent execute 'iscsi device login|logout' and
> > 'multipath -r' command with IO stress on multipath device.
> > In some case, systemd-udevd may have not time to process
> > uevents of iscsi device logout|login, and then 'multipath -r'
> > command triggers multipathd daemon calls ioctl to load table
> > with incorrect old device info from systemd-udevd.
> > Then, one iscsi path may be incorrectly attached to another
> > multipath which has different uuid. Finally, the metadata err
> > occurs when umounting filesystem to down write metadata on
> > the iscsi device which is actually not owned by the multipath
> > device.
> > 
> > So we need to check whether all pgpaths of one multipath have
> > the same uuid, if not, we should throw a error.
> > 
> > Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> > Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
> > Signed-off-by: linfeilong <linfeilong@huawei.com>
> > Signed-off-by: Wubo <wubo40@huawei.com>
> > ---
> >  drivers/md/dm-mpath.c   | 52 +++++++++++++++++++++++++++++++++++++++++
> >  drivers/scsi/scsi_lib.c |  1 +
> >  2 files changed, 53 insertions(+)
> > 
> > diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
> > index bced42f082b0..f0b995784b53 100644
> > --- a/drivers/md/dm-mpath.c
> > +++ b/drivers/md/dm-mpath.c
> > @@ -24,6 +24,7 @@
> >  #include <linux/workqueue.h>
> >  #include <linux/delay.h>
> >  #include <scsi/scsi_dh.h>
> > +#include <linux/dm-ioctl.h>
> >  #include <linux/atomic.h>
> >  #include <linux/blk-mq.h>
> > 
> > @@ -1169,6 +1170,45 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
> >  	return r;
> >  }
> > 
> > +#define SCSI_VPD_LUN_ID_PREFIX_LEN 4
> > +#define MPATH_UUID_PREFIX_LEN 7
> > +static int check_pg_uuid(struct priority_group *pg, char *md_uuid)
> > +{
> > +	char pgpath_uuid[DM_UUID_LEN] = {0};
> > +	struct request_queue *q;
> > +	struct pgpath *pgpath;
> > +	struct scsi_device *sdev;
> > +	ssize_t count;
> > +	int r = 0;
> > +
> > +	list_for_each_entry(pgpath, &pg->pgpaths, list) {
> > +		q = bdev_get_queue(pgpath->path.dev->bdev);
> > +		sdev = scsi_device_from_queue(q);
> 
> Common dm-multipath code should never poke into scsi internals.  This
> is something for the device handler to check.  It probably also won't
> work for all older devices.

Definitely.

But that aside, userspace (multipathd) _should_ be able to do extra
validation, _before_ pushing down a new table to the kernel, rather than
forcing the kernel to do it.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@redhat.com>
To: Christoph Hellwig <hch@infradead.org>,
	Zhiqiang Liu <liuzhiqiang26@huawei.com>
Cc: agk@redhat.com, dm-devel@redhat.com,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	linfeilong <linfeilong@huawei.com>,
	lixiaokeng <lixiaokeng@huawei.com>,
	"wubo (T)" <wubo40@huawei.com>
Subject: Re: md/dm-mpath: check whether all pgpaths have same uuid in multipath_ctr()
Date: Mon, 22 Mar 2021 10:22:07 -0400	[thread overview]
Message-ID: <20210322142207.GB30698@redhat.com> (raw)
In-Reply-To: <20210322081155.GE1946905@infradead.org>

On Mon, Mar 22 2021 at  4:11am -0400,
Christoph Hellwig <hch@infradead.org> wrote:

> On Sat, Mar 20, 2021 at 03:19:23PM +0800, Zhiqiang Liu wrote:
> > From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> > 
> > When we make IO stress test on multipath device, there will
> > be a metadata err because of wrong path. In the test, we
> > concurrent execute 'iscsi device login|logout' and
> > 'multipath -r' command with IO stress on multipath device.
> > In some case, systemd-udevd may have not time to process
> > uevents of iscsi device logout|login, and then 'multipath -r'
> > command triggers multipathd daemon calls ioctl to load table
> > with incorrect old device info from systemd-udevd.
> > Then, one iscsi path may be incorrectly attached to another
> > multipath which has different uuid. Finally, the metadata err
> > occurs when umounting filesystem to down write metadata on
> > the iscsi device which is actually not owned by the multipath
> > device.
> > 
> > So we need to check whether all pgpaths of one multipath have
> > the same uuid, if not, we should throw a error.
> > 
> > Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> > Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
> > Signed-off-by: linfeilong <linfeilong@huawei.com>
> > Signed-off-by: Wubo <wubo40@huawei.com>
> > ---
> >  drivers/md/dm-mpath.c   | 52 +++++++++++++++++++++++++++++++++++++++++
> >  drivers/scsi/scsi_lib.c |  1 +
> >  2 files changed, 53 insertions(+)
> > 
> > diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
> > index bced42f082b0..f0b995784b53 100644
> > --- a/drivers/md/dm-mpath.c
> > +++ b/drivers/md/dm-mpath.c
> > @@ -24,6 +24,7 @@
> >  #include <linux/workqueue.h>
> >  #include <linux/delay.h>
> >  #include <scsi/scsi_dh.h>
> > +#include <linux/dm-ioctl.h>
> >  #include <linux/atomic.h>
> >  #include <linux/blk-mq.h>
> > 
> > @@ -1169,6 +1170,45 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
> >  	return r;
> >  }
> > 
> > +#define SCSI_VPD_LUN_ID_PREFIX_LEN 4
> > +#define MPATH_UUID_PREFIX_LEN 7
> > +static int check_pg_uuid(struct priority_group *pg, char *md_uuid)
> > +{
> > +	char pgpath_uuid[DM_UUID_LEN] = {0};
> > +	struct request_queue *q;
> > +	struct pgpath *pgpath;
> > +	struct scsi_device *sdev;
> > +	ssize_t count;
> > +	int r = 0;
> > +
> > +	list_for_each_entry(pgpath, &pg->pgpaths, list) {
> > +		q = bdev_get_queue(pgpath->path.dev->bdev);
> > +		sdev = scsi_device_from_queue(q);
> 
> Common dm-multipath code should never poke into scsi internals.  This
> is something for the device handler to check.  It probably also won't
> work for all older devices.

Definitely.

But that aside, userspace (multipathd) _should_ be able to do extra
validation, _before_ pushing down a new table to the kernel, rather than
forcing the kernel to do it.


  reply	other threads:[~2021-03-22 14:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-20  7:19 [dm-devel] [PATCH] md/dm-mpath: check whether all pgpaths have same uuid in multipath_ctr() Zhiqiang Liu
2021-03-20  7:19 ` Zhiqiang Liu
2021-03-20 14:34 ` [dm-devel] " kernel test robot
2021-03-20 14:34   ` kernel test robot
2021-03-20 14:34   ` kernel test robot
2021-03-22  8:11 ` [dm-devel] " Christoph Hellwig
2021-03-22  8:11   ` Christoph Hellwig
2021-03-22 14:22   ` Mike Snitzer [this message]
2021-03-22 14:22     ` Mike Snitzer
2021-03-23  7:47     ` [dm-devel] " lixiaokeng
2021-03-23  7:47       ` lixiaokeng
2021-03-23 17:11       ` [dm-devel] " Ewan D. Milne
2021-03-23 17:11         ` Ewan D. Milne
2021-03-25  1:12         ` [dm-devel] " Zhiqiang Liu
2021-03-25  1:12           ` Zhiqiang Liu
2021-03-25  1:21     ` [dm-devel] " Zhiqiang Liu
2021-03-25  1:21       ` Zhiqiang Liu
2021-03-25 15:14       ` [dm-devel] " Mike Snitzer
2021-03-25 15:14         ` Mike Snitzer
2021-03-26 17:12         ` [dm-devel] " Martin Wilck
2021-03-26 17:12           ` Martin Wilck

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=20210322142207.GB30698@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=jejb@linux.ibm.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=lixiaokeng@huawei.com \
    --cc=martin.petersen@oracle.com \
    --cc=wubo40@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.