From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Snitzer Subject: Re: fix reversed logic in device_area_is_valid Date: Mon, 27 Jul 2009 10:15:07 -0400 Message-ID: <20090727141506.GA4964@redhat.com> References: Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Mikulas Patocka Cc: device-mapper development , Alasdair G Kergon List-Id: dm-devel.ids On Mon, Jul 27 2009 at 9:21am -0400, Mikulas Patocka wrote: > Hi > > This patch fixes a bug introduced in 2.6.31-rc1. Targets that define > iterate_devices and don't contain any devices (such as dm-loop in fsio) > don't work. > > Mikulas > > --- > > Fix reverse logic in device_area_is_valid > > ->iterate_devices method calls the callback for every underlying device > in the target. If the callback returns non-zero, iterate_devices exits > and returns this value. If the callback returns zero for all the devices, > iterate_devices returns zero. > > The logic to check for invalid device areas was reversed. > device_area_is_valid returned 0 on error and 1 on success. > > Thus: > - error was returned only if all the devices vere errorneous. If some of them > returned 1 (success), dm_calculate_queue_limits understood this as success. > - if the target had no device (the example is dm-loop target in FSIO mode), > iterate_devices returned error straight away and dm_calculate_queue_limits > understood this as an error. > > This patch reverses the logic so that 0 means success and 1 means error. > > Signed-off-by: Mikulas Patocka Nice catch, interesting that this was somehow missed. All targets do treat a non-zero return from .iterate_devices as an error. We should probably rename device_area_is_valid to device_area_invalid. Mike