Re: [Nbd] [PATCH 1/6] block: export blkdev_reread_part()
- To: Christoph Hellwig <hch@...1270...>
- Cc: Jens Axboe <axboe@...161...>, "nbd-general@lists.sourceforge.net" <nbd-general@lists.sourceforge.net>, linux-s390@...25..., Stefan Haberland <stefan.haberland@...1296...>, Sebastian Ott <sebott@...1294...>, Linux Kernel Mailing List <linux-kernel@...25...>, Jarod Wilson <jarod@...696...>, Fabian Frederick <fabf@...1980...>, Alexander Viro <viro@...1300...>, David Herrmann <dh.herrmann@...17...>, Tejun Heo <tj@...1285...>, Andrew Morton <akpm@...133...>
- Subject: Re: [Nbd] [PATCH 1/6] block: export blkdev_reread_part()
- From: Ming Lei <ming.lei@...1301...>
- Date: Tue, 7 Apr 2015 10:11:53 +0800
- Message-id: <CACVXFVNHpUyM3QYUKCxvhx9N2ec0=pcLY2snCt-BOX_dqZtTHw@...18...>
- In-reply-to: <20150406145048.GC2703@...1270...>
- References: <1428218688-4092-1-git-send-email-ming.lei@...1301...> <1428218688-4092-2-git-send-email-ming.lei@...1301...> <20150405161241.GB16886@...1270...> <CACVXFVP-rokGRrMus_QXju+MVzFPTaFC45oZBe2PEBfbid8nmQ@...18...> <20150406145048.GC2703@...1270...>
On Mon, Apr 6, 2015 at 10:50 PM, Christoph Hellwig <hch@...1270...> wrote:
> On Mon, Apr 06, 2015 at 12:40:12AM +0800, Ming Lei wrote:
>> > int blkdev_reread_part(struct block_device *bdev)
>> > {
>> > if (!mutex_trylock(&bdev->bd_mutex))
>> > return -EBUSY;
>> > blkdev_reread_part_nolock(bdev);
>> > mutex_unlock(&bdev->bd_mutex);
>> > }
>>
>> Yes, it is more clean, but with extra acquiring lock cost for the
>> failure cases, especially when we replace trylock with mutex_lock().
>
> It's just a few fairly trivial checks, so 'm not really worried about
> it, especially given that blkdev_reread_part isn't called from a fast
> path.
OK, considered that common users don't have any privilege
on block devices at default in most distributions, so they can't
do DoS by running ioctl(RRPART) with this change.
I will change to this style in v1.
Thanks,
Ming Lei
Reply to: