From patchwork Wed Aug 5 19:13:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 6952561 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 61479C05AC for ; Wed, 5 Aug 2015 19:13:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DB4A203A5 for ; Wed, 5 Aug 2015 19:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7873B20383 for ; Wed, 5 Aug 2015 19:13:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751867AbbHETNJ (ORCPT ); Wed, 5 Aug 2015 15:13:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60537 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751536AbbHETNI (ORCPT ); Wed, 5 Aug 2015 15:13:08 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id EAB1DE7C9C; Wed, 5 Aug 2015 19:13:07 +0000 (UTC) Received: from Liberator.local (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t75JD69I022306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 5 Aug 2015 15:13:07 -0400 Message-ID: <55C26043.20002@redhat.com> Date: Wed, 05 Aug 2015 12:13:07 -0700 From: Eric Sandeen MIME-Version: 1.0 To: "linux-fsdevel@vger.kernel.org" CC: Jens Axboe Subject: [PATCH] block: return EBUSY from drop_partitions on mounted whole disk device X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The BLKRRPART ioctl already fails today if any partition under the device is mounted. However, if we mkfs a whole disk and mount it, BLKRRPART happily proceeds down the invalidation path, which seems like a bad idea. Check whether the whole device is mounted by checking bd_super, and return -EBUSY if so. Signed-off-by: Eric Sandeen --- I don't know for sure if this is the right approach, but figure I'll ask in the form of a patch. ;) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/block/partition-generic.c b/block/partition-generic.c index 0d9e5f9..04f304c 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -397,7 +397,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev) struct hd_struct *part; int res; - if (bdev->bd_part_count) + if (bdev->bd_super || bdev->bd_part_count) return -EBUSY; res = invalidate_partition(disk, 0); if (res)