From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Snitzer Subject: Re: confusion about multipath_prepare_ioctl Date: Tue, 6 Mar 2018 00:44:22 -0500 Message-ID: <20180306054422.GA19607@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Wang Sheng-Hui Cc: dm-devel , hch List-Id: dm-devel.ids On Mon, Mar 05 2018 at 10:35pm -0500, Wang Sheng-Hui wrote: > Dear, > > Sorry to trouble you. > > I noticed some code in dm-*.c like: > " > static int multipath_prepare_ioctl(struct dm_target *ti, > struct block_device **bdev, fmode_t *mode) > { > ... > /* > * Only pass ioctls through if the device sizes match exactly. > */ > if (!r && ti->len != i_size_read((*bdev)->bd_inode) >> SECTOR_SHIFT) > return 1; > ... > } > " > Here, return value 1 means > "ioctl is being issued against a subset of the parent bdev; require extra privileges." > (comment in dm_blk_ioctl) > > I'm confused by the comment and '!=' test for multipath. > In which cases, the size of low level single device is not equal to the parent > size of multipath device? Given that ti->len is sent down from userspace, the DM multipath target's ti->len _could_ be smaller than the underlying path(s). But in practice that doesn't occur with multipathd.. a partitioned multipath device is generally done, via kpartx, in terms of linear mappings ontop of the multipath device. The same != test is done in the dm linear target and is much more relevant to concerns about ioctls being sent to partition. Mike