From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936100AbdDSOvX (ORCPT ); Wed, 19 Apr 2017 10:51:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47350 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935742AbdDSOp2 (ORCPT ); Wed, 19 Apr 2017 10:45:28 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , Jens Axboe , Ben Hutchings Subject: [PATCH 4.9 56/69] nbd: use loff_t for blocksize and nbd_set_size args Date: Wed, 19 Apr 2017 16:43:12 +0200 Message-Id: <20170419141619.220497997@linuxfoundation.org> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170419141616.919951169@linuxfoundation.org> References: <20170419141616.919951169@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik commit ef77b515243b3499d62cf446eda6ca7e0a0b079c upstream. If we have large devices (say like the 40t drive I was trying to test with) we will end up overflowing the int arguments to nbd_set_size and not get the right size for our device. Fix this by using loff_t everywhere so I don't have to think about this again. Thanks, Signed-off-by: Josef Bacik Signed-off-by: Jens Axboe [bwh: Backported to 4.9: adjust context] Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/block/nbd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -54,7 +54,7 @@ struct nbd_device { struct mutex tx_lock; struct gendisk *disk; - int blksize; + loff_t blksize; loff_t bytesize; /* protects initialization and shutdown of the socket */ @@ -126,7 +126,7 @@ static void nbd_size_update(struct nbd_d } static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, - int blocksize, int nr_blocks) + loff_t blocksize, loff_t nr_blocks) { int ret; @@ -135,7 +135,7 @@ static int nbd_size_set(struct nbd_devic return ret; nbd->blksize = blocksize; - nbd->bytesize = (loff_t)blocksize * (loff_t)nr_blocks; + nbd->bytesize = blocksize * nr_blocks; nbd_size_update(nbd, bdev); @@ -817,7 +817,7 @@ static int nbd_dev_dbg_init(struct nbd_d debugfs_create_file("tasks", 0444, dir, nbd, &nbd_dbg_tasks_ops); debugfs_create_u64("size_bytes", 0444, dir, &nbd->bytesize); debugfs_create_u32("timeout", 0444, dir, &nbd->tag_set.timeout); - debugfs_create_u32("blocksize", 0444, dir, &nbd->blksize); + debugfs_create_u64("blocksize", 0444, dir, &nbd->blksize); debugfs_create_file("flags", 0444, dir, nbd, &nbd_dbg_flags_ops); return 0;