Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3242724pxf; Mon, 22 Mar 2021 01:16:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlLNnVa4xYtE/LDIQrmCHv7fGL2mnLR8ImnZ8zRTZqQDDYK1VcxQKYXUXBG0VrKfs82YV+ X-Received: by 2002:a17:906:71c3:: with SMTP id i3mr17879524ejk.391.1616400969943; Mon, 22 Mar 2021 01:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616400969; cv=none; d=google.com; s=arc-20160816; b=1AkVZjv5RgdgZIALfrEQ7Z+DBLrg3zxm7nFFsXxCO+2UiKScp+A2vWNJbM+m6mYLW2 goQfDQjxocVZBcuyvfkZKHi5cvy1oxfabfPMKjZ/3gWQtCRK8Qn/XziHU4UmeZadGNBQ sVyOCodUPFQzNAjucH/NH2xxBn4Pr2bSSuvcQ+KigdjSLh3wtxSfDLgxTxoBfrzwvWJh qMO7YbausHffo+XyRbl0BgLuC/OeG/IJpdU/coars/l+Nx4wUwdtL6vJ6p7DedgfA6vD d4/nk3+B5NnO5sb/c6gx2wQEUqoEGVpbixx62gfd5XIdB/x13OdQQifai9ZY7fKb5DS1 U7uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZNtQiL6tIyqch+BmC79W/NJ6n9Wo/6qrrvbdpMthN14=; b=MbOK7GGZ/racVowVhTbGKXi/k/5eYvzvb59w4lRonea2PufyvhEMxMwrdl0dIP1sZl o/BY8QVr3KZE6zOtqx6x2sYihmbuoKSqOl3gHxjjs3nSZjZI5ejz7mpWA31+1SjZbBXz Pk4fmDyfvtg8x6r/BNZHiEfE8cj1riXhPrAkjDJVIzYAVDncy/8gzYUHfEYKSyNHeBJC 8z8m+t46u1ZI9ehOspXU6V1kU/495Rrib2FgOegTwftykX6XM95tcRIi7J1XGNQtoj4J JBZYPO+WwjWHK0ekZuv7fEoqhFA9KmXnvHEhDHBQ6Wstgiz40RJJjpOZJwK7oOTw6nEE RJZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Z3czrzgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz16si10794663ejb.586.2021.03.22.01.15.47; Mon, 22 Mar 2021 01:16:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Z3czrzgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbhCVINi (ORCPT + 99 others); Mon, 22 Mar 2021 04:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbhCVIN2 (ORCPT ); Mon, 22 Mar 2021 04:13:28 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7F43C061574; Mon, 22 Mar 2021 01:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZNtQiL6tIyqch+BmC79W/NJ6n9Wo/6qrrvbdpMthN14=; b=Z3czrzgs7g5m4PHydjpPMdqmv9 XAPLDRUQpzn10rX3V6rakbFpXs2+E53sFwZrExGGHF7yVLyUzCWK55lH+zkFkkfJpEkGLDHnh0HHp 1cLEcYc9ASJpHqon3wKbDQpm5U5S8AFs9UxC+MEq0XBMlhnP7vPY3YFCLBfaaAXyP3DHTsST9dFgh 9ce39twENQO+bQlzOg1krJL6200dlTDX1N1kYrw2TTxDB5FXnc1tSFCyd/jGYNJ4z9d58Lqj32KU2 LdosiNGSNlpu6SdPPlLT+4NyGvS1HcYi69HuA5WMpoH8LB1I68VV0a7Ewbj70iGWweya26MoPR2vW gmhHNx/A==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lOFfH-008Btj-KA; Mon, 22 Mar 2021 08:12:09 +0000 Date: Mon, 22 Mar 2021 08:11:55 +0000 From: Christoph Hellwig To: Zhiqiang Liu Cc: agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, linfeilong , lixiaokeng , "wubo (T)" Subject: Re: [PATCH] md/dm-mpath: check whether all pgpaths have same uuid in multipath_ctr() Message-ID: <20210322081155.GE1946905@infradead.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 20, 2021 at 03:19:23PM +0800, Zhiqiang Liu wrote: > From: Zhiqiang Liu > > 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 > Signed-off-by: lixiaokeng > Signed-off-by: linfeilong > Signed-off-by: Wubo > --- > 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 > #include > #include > +#include > #include > #include > > @@ -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.