From: Florian Weimer Subject: Re: FIBMAP/FIEMAP discrepancy for CAP_SYS_RAWIO Date: Mon, 07 Sep 2009 16:26:22 +0000 Message-ID: <87y6oqd8lt.fsf@mid.deneb.enyo.de> References: <87y6osry4k.fsf@mid.deneb.enyo.de> <20090907105014.GV4197@webber.adilger.int> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org To: Andreas Dilger Return-path: Received: from mail.enyo.de ([212.9.189.167]:53323 "EHLO mail.enyo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753513AbZIGQ0V (ORCPT ); Mon, 7 Sep 2009 12:26:21 -0400 In-Reply-To: <20090907105014.GV4197@webber.adilger.int> (Andreas Dilger's message of "Mon, 07 Sep 2009 12:50:14 +0200") Sender: linux-fsdevel-owner@vger.kernel.org List-ID: * Andreas Dilger: > On Sep 06, 2009 13:39 +0000, Florian Weimer wrote: >> The FIBMAP ioctl requires CAP_SYS_RAWIO, but FIEMAP doesn't. Why's >> that? Is it that there is no backwards-compatible way to introduce >> locking on the bmap path? > > I'm not sure why there is a root-only requirement for FIBMAP, but the > FIEMAP data is definitely useful even for non-root users for many > reasons, such as optimized file copies/rsync/tar/etc skipping holes > in sparse files easily. I'm slightly worried because the generic FIEMAP-on-FIBMAP implementation takes the inode mutex, but the FIBMAP ioctl doesn't. > If you are implementing a tool to use this, I would code it to try > FIEMAP first, then FIBMAP (if it is running as root, or it gets > fixed in some future kernel), then just do without (as it most likely > does already today). If FIBMAP is unsafe, it's likely exposed by concurrent changes to the file, so using it would still be unsafe for backup purposes. And I really only need the number of the first block. (I want to optimize reading of Maildir-style folders, mainly for backup purposes.)