Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21160310ybl; Sun, 5 Jan 2020 22:03:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwc0PYFQ6P0Vu8IKV5R5bXvRbKh+/nhHO26Z7CRs7iCm6/9TU0HL2bNJb1u1f1GWHVvgVq3 X-Received: by 2002:a05:6830:109a:: with SMTP id y26mr108095854oto.227.1578290585572; Sun, 05 Jan 2020 22:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578290585; cv=none; d=google.com; s=arc-20160816; b=Q7i4075GEgGTi84remviwZ0ZW/Odb1R73E7vnhBAj6zwlnF67KU6aly3r0HcPbnbYn vsuvCEnh+va6GERrzxadSIOsEzwT/BGeOyjB385+lld8Q9P0XSuFaKR+GZVK5qyfJgbV bMkdwC1W89HDmetanNdAdBDMXoie24w8pYZRMmptcr+/dO4PFFI36GogWuCicepN0D95 bILciYLsV9y2rF6VvfLUY1MkCyBSSe6eAfeO2tMu0ZQeVat2MrH+BWDxFTpYJuCNOqbx v501YJ5HMeklZCWHWUFZUkUtzceqn22bQn5SNLy7yOSHD3IKBXSRxZqqTmw3Fs73HFSD 0TWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=0zelCiREPyenR2QYtmR9ZeGfHkO4MI8l17JPDOcphVg=; b=wPO8QD+RUcWRGUKOwpz0dfmz4Ptcf6u5RaE2iVRpgd8a9L9MNZ8t2Z1LMkt4xdOW5H WTlDKS4mRCa1VUpXGZ4ioKNFtf4EBUFytAOHbXQc+6l1GkCmHkaeJRpWEFGY/VQTdzBl KF1RnS+a4pmukSP3TSpQZPgUrbxihSOyI2WncivKM67otST0Kqah8zo96h961VfzKjsu WA8BfYUpICklBrURxdMIr5292rHWGcJYhgGs2gqSjZ7rRKze4kbV7ETAe5RyF4aYnra8 365SczkX1OcVyykLLQWFX68Mg5aV/xqQ6cR75WsxlnXcsookWg+YfhP/O9kHcDip0+o2 88UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=sQrqpLYN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si13662610otc.160.2020.01.05.22.02.51; Sun, 05 Jan 2020 22:03:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=sQrqpLYN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbgAFGB4 (ORCPT + 99 others); Mon, 6 Jan 2020 01:01:56 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:49338 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726338AbgAFGB4 (ORCPT ); Mon, 6 Jan 2020 01:01:56 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0065jCiE006637; Mon, 6 Jan 2020 06:01:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=0zelCiREPyenR2QYtmR9ZeGfHkO4MI8l17JPDOcphVg=; b=sQrqpLYNqHigKlPsXLD1kuu8LIRjyyWMsVV4wmHH9w/UvRbuExo0savdiJmZvNFthqfQ 58o3LA5r10qOYNnumg1q5NsNGkTDZZe8rBF67BcPkFIJzZzrgEmEsncjqKWQEJuUaBeE CAktISzxwKnPH2nk+pkBi2hZNa0wiX/B3prEWih0GfpPt2ibeLcEuAyuTwK5b70OaFzu 8FbDEzf5+9VIeC/rCxo88Vk3bGdlDbTTdgdLCkA5tnxTS6SGvEHskmXQJdgPxaJNU/gt /EOkwApdrM6eV6qVYzc1Yis7SQNKK/rJnpHxIP5sF8cHFWraxelIis+nsHuNmxAh7TR1 lA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2xakbqd35h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Jan 2020 06:01:32 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0065iY14075592; Mon, 6 Jan 2020 05:59:32 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2xb47b5mfx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Jan 2020 05:59:32 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0065xOPm032657; Mon, 6 Jan 2020 05:59:25 GMT Received: from [192.168.1.14] (/114.88.246.185) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 05 Jan 2020 21:59:24 -0800 Subject: Re: [resend v1 0/5] Add support for block disk resize notification To: Balbir Singh , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: axboe@kernel.dk, ssomesh@amazon.com, jejb@linux.ibm.com, hch@lst.de, mst@redhat.com, Chaitanya.Kulkarni@wdc.com References: <20200102075315.22652-1-sblbir@amazon.com> From: Bob Liu Message-ID: <62ef2cd2-42a2-6117-155d-ed052a136c5c@oracle.com> Date: Mon, 6 Jan 2020 13:59:17 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20200102075315.22652-1-sblbir@amazon.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9491 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=913 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001060053 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9491 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=957 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001060053 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/2/20 3:53 PM, Balbir Singh wrote: > Allow block/genhd to notify user space about disk size changes > using a new helper disk_set_capacity(), which is a wrapper on top > of set_capacity(). disk_set_capacity() will only notify if > the current capacity or the target capacity is not zero. > set_capacity_and_notify() may be a more straightforward name. > Background: > > As a part of a patch to allow sending the RESIZE event on disk capacity > change, Christoph (hch@lst.de) requested that the patch be made generic > and the hacks for virtio block and xen block devices be removed and > merged via a generic helper. > > This series consists of 5 changes. The first one adds the basic > support for changing the size and notifying. The follow up patches > are per block subsystem changes. Other block drivers can add their > changes as necessary on top of this series. > > Testing: > 1. I did some basic testing with an NVME device, by resizing it in > the backend and ensured that udevd received the event. > > NOTE: After these changes, the notification might happen before > revalidate disk, where as it occured later before. > It's better not to change original behavior. How about something like: +void set_capacity_and_notify(struct gendisk *disk, sector_t size, bool revalidate) { sector_t capacity = get_capacity(disk); set_capacity(disk, size); + if (revalidate) + revalidate_disk(disk); if (capacity != 0 && size != 0) { char *envp[] = { "RESIZE=1", NULL }; kobject_uevent_env(&disk_to_dev(disk)->kobj, KOBJ_CHANGE, envp); } } > Balbir Singh (5): > block/genhd: Notify udev about capacity change > drivers/block/virtio_blk.c: Convert to use disk_set_capacity > drivers/block/xen-blkfront.c: Convert to use disk_set_capacity > drivers/nvme/host/core.c: Convert to use disk_set_capacity > drivers/scsi/sd.c: Convert to use disk_set_capacity > > block/genhd.c | 19 +++++++++++++++++++ > drivers/block/virtio_blk.c | 4 +--- > drivers/block/xen-blkfront.c | 5 +---- > drivers/nvme/host/core.c | 2 +- > drivers/scsi/sd.c | 2 +- > include/linux/genhd.h | 1 + > 6 files changed, 24 insertions(+), 9 deletions(-) >