Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp51648pxf; Wed, 24 Mar 2021 20:42:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHVKAHZTGVbAXZMMIwmiy8ZH8n+Jx94k4nFuT9JUgKhjZYEaHjsBvx9pGmSkOZHEN6JN7N X-Received: by 2002:a17:906:b316:: with SMTP id n22mr6890265ejz.249.1616643764627; Wed, 24 Mar 2021 20:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616643764; cv=none; d=google.com; s=arc-20160816; b=JIvORzCr9x4oTc3tUlkmyYiiE80WEYW6O3Zx0Ij1Lfmf8svXxLD25oKApPv1LOGlQz l0aaUBJhj11o0KIEPE3uMxHtyGnZSlSroSrfbZiNi6U6+D/w1XnPwhtULwRG6rfX1MBZ 1hFCz/2A+cBMXAw9yMhRKAf4AOd8wGDIg0mw7RiqSQ5V2/5XJSJRopccbvx68PblI5Uu olfNl791wYwWeeT7e496rrUb/uuxYrVLy+EgV7AfECknTUdFKI6HfUQkVrCylw1xB6gf 8NAvOFnuipfgAYANFP3TXY6rdzDh1fLm9bsZWDBBLZWs3u+NhO9vD7xQU7UjVOC1Nhag Cbzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=N4jptWdWKTm06deXxcomPt+mG/5xmCeoUZPnC2vT4u0=; b=H3u7xko+oW46BMT2MbjqOHantYZJ8Mc/qx+UwkB16IdYxMxt6FFsGxlr1mvZoSE/nf PUDB6MIGBBLLNJQ/2NlNuqQA6kjvj96P31GqLO9mxPY0A5Ul2v3jrF+2s1G2aEkoWCpM vsOM35fD4ANGpmDE+SGOrSR6OIDl5Df1vktu1xOlYGFM48fpWvY6IkNSbZQblcRg2CGM NQ+lEHiwCjCq/nUkZagPG/9hFAxowvm+m611mP+K711zQxdhZ9TheJ/3vcGWN3Mw9o8T +dkP44595nowk/pVU8QmM7HOjwa5qCZdLU7ZGJ5z31ej6ldi+J+7JdqXTQGoa91MFWnZ 5Eug== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si3315374edt.436.2021.03.24.20.42.22; Wed, 24 Mar 2021 20:42:44 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235552AbhCYBWX (ORCPT + 99 others); Wed, 24 Mar 2021 21:22:23 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14525 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239566AbhCYBWC (ORCPT ); Wed, 24 Mar 2021 21:22:02 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F5S1r5WxszNmxN; Thu, 25 Mar 2021 09:19:28 +0800 (CST) Received: from [127.0.0.1] (10.174.176.117) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Thu, 25 Mar 2021 09:21:51 +0800 Subject: Re: md/dm-mpath: check whether all pgpaths have same uuid in multipath_ctr() To: Mike Snitzer , Christoph Hellwig CC: , , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , , , linfeilong , lixiaokeng , "wubo (T)" References: <20210322081155.GE1946905@infradead.org> <20210322142207.GB30698@redhat.com> From: Zhiqiang Liu Message-ID: Date: Thu, 25 Mar 2021 09:21:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20210322142207.GB30698@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.117] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/22 22:22, Mike Snitzer wrote: > On Mon, Mar 22 2021 at 4:11am -0400, > Christoph Hellwig wrote: > >> 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. > > 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. As your said, it is better to do extra validation in userspace (multipathd). However, in some cases, the userspace cannot see the real-time present devices info as Martin (committer of multipath-tools) said. In addition, the kernel can see right device info in the table at any time, so the uuid check in kernel can ensure one multipath is composed with paths mapped to the same device. Considering the severity of the wrong path in multipath, I think it worths more checking. Regards Zhiqiang Liu. > > . >