On Thu, Apr 25, 2013 at 03:04:04PM -0700, Andy Grover wrote: > if the fileio backing file is actually a block device, fd_dev_size will > be 0. Ensure we return the correct value by calling fd_get_blocks() and > multiplying by block size. > > Move fd_get_blocks in source file, so fd_show_configfs_dev_params can > call it. > > Signed-off-by: Andy Grover <agrover@xxxxxxxxxx> I saw this issue for a while and this patch works for me. One minor nits inline. Otherwise, Tested-by: Asias He <asias@xxxxxxxxxx> Reviewed-by: Asias He <asias@xxxxxxxxxx> > --- > drivers/target/target_core_file.c | 29 ++++++++++++++++------------- > 1 files changed, 16 insertions(+), 13 deletions(-) > > diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c > index 58ed683..2330dc4 100644 > --- a/drivers/target/target_core_file.c > +++ b/drivers/target/target_core_file.c > @@ -674,19 +674,6 @@ out: > return (!ret) ? count : ret; > } > > -static ssize_t fd_show_configfs_dev_params(struct se_device *dev, char *b) > -{ > - struct fd_dev *fd_dev = FD_DEV(dev); > - ssize_t bl = 0; > - > - bl = sprintf(b + bl, "TCM FILEIO ID: %u", fd_dev->fd_dev_id); > - bl += sprintf(b + bl, " File: %s Size: %llu Mode: %s\n", > - fd_dev->fd_dev_name, fd_dev->fd_dev_size, > - (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) ? > - "Buffered-WCE" : "O_DSYNC"); > - return bl; > -} > - > static sector_t fd_get_blocks(struct se_device *dev) > { > struct fd_dev *fd_dev = FD_DEV(dev); > @@ -706,6 +693,22 @@ static sector_t fd_get_blocks(struct se_device *dev) > return div_u64(dev_size, dev->dev_attrib.block_size); > } > > +static ssize_t fd_show_configfs_dev_params(struct se_device *dev, char *b) > +{ > + struct fd_dev *fd_dev = FD_DEV(dev); > + ssize_t bl = 0; > + long long unsigned int dev_size; Why not use 'unsigned long long' as we do in fd_get_blocks() for dev_size or 'unsigned long long int' if you really prefer the int. > + > + dev_size = fd_get_blocks(dev) * dev->dev_attrib.block_size; > + > + bl = sprintf(b + bl, "TCM FILEIO ID: %u", fd_dev->fd_dev_id); > + bl += sprintf(b + bl, " File: %s Size: %llu Mode: %s\n", > + fd_dev->fd_dev_name, dev_size, > + (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) ? > + "Buffered-WCE" : "O_DSYNC"); > + return bl; > +} > + > static struct sbc_ops fd_sbc_ops = { > .execute_rw = fd_execute_rw, > .execute_sync_cache = fd_execute_sync_cache, > -- > 1.7.1 > > -- > To unsubscribe from this list: send the line "unsubscribe target-devel" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Asias -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html