Patch "target/file: Fix off-by-one READ_CAPACITY bug for !S_ISBLK export" has been added to the 3.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    target/file: Fix off-by-one READ_CAPACITY bug for !S_ISBLK export

to the 3.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     target-file-fix-off-by-one-read_capacity-bug-for-s_isblk-export.patch
and it can be found in the queue-3.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 21363ca873334391992f2f424856aa864345bb61 Mon Sep 17 00:00:00 2001
From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
Date: Wed, 29 May 2013 21:35:23 -0700
Subject: target/file: Fix off-by-one READ_CAPACITY bug for !S_ISBLK export

From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>

commit 21363ca873334391992f2f424856aa864345bb61 upstream.

This patch fixes a bug where FILEIO was incorrectly reporting the number
of logical blocks (+ 1) when using non struct block_device export mode.

It changes fd_get_blocks() to follow all other backend ->get_blocks() cases,
and reduces the calculated dev_size by one dev->dev_attrib.block_size
number of bytes, and also fixes initial fd_block_size assignment at
fd_configure_device() time introduced in commit 0fd97ccf4.

Reported-by: Wenchao Xia <xiawenc@xxxxxxxxxxxxxxxxxx>
Reported-by: Badari Pulavarty <pbadari@xxxxxxxxxx>
Tested-by: Badari Pulavarty <pbadari@xxxxxxxxxx>
Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
Signed-off-by: Lingzhu Xiang <lxiang@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
 drivers/target/target_core_file.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -150,6 +150,7 @@ static int fd_configure_device(struct se
 	if (S_ISBLK(inode->i_mode)) {
 		unsigned long long dev_size;
 
+		fd_dev->fd_block_size = bdev_logical_block_size(inode->i_bdev);
 		/*
 		 * Determine the number of bytes from i_size_read() minus
 		 * one (1) logical sector from underlying struct block_device
@@ -168,11 +169,11 @@ static int fd_configure_device(struct se
 				" block_device\n");
 			goto fail;
 		}
-	}
 
-	fd_dev->fd_block_size = dev->dev_attrib.hw_block_size;
+		fd_dev->fd_block_size = FD_BLOCKSIZE;
+	}
 
-	dev->dev_attrib.hw_block_size = FD_BLOCKSIZE;
+	dev->dev_attrib.hw_block_size = fd_dev->fd_block_size;
 	dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS;
 	dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH;
 
@@ -583,11 +584,12 @@ static sector_t fd_get_blocks(struct se_
 	 * to handle underlying block_device resize operations.
 	 */
 	if (S_ISBLK(i->i_mode))
-		dev_size = (i_size_read(i) - fd_dev->fd_block_size);
+		dev_size = i_size_read(i);
 	else
 		dev_size = fd_dev->fd_dev_size;
 
-	return div_u64(dev_size, dev->dev_attrib.block_size);
+	return div_u64(dev_size - dev->dev_attrib.block_size,
+		       dev->dev_attrib.block_size);
 }
 
 static struct sbc_ops fd_sbc_ops = {


Patches currently in stable-queue which might be from nab@xxxxxxxxxxxxxxx are

queue-3.9/iscsi-target-fix-heap-buffer-overflow-on-error.patch
queue-3.9/target-file-fix-off-by-one-read_capacity-bug-for-s_isblk-export.patch
queue-3.9/ib_srpt-call-target_sess_cmd_list_set_waiting-during-shutdown_session.patch
queue-3.9/target-re-instate-sess_wait_list-for-target_wait_for_sess_cmds.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]