From 81ee28de860095cc0c063b92eea53cb97771f796 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 28 Dec 2015 11:57:39 -0800 Subject: target/user: Allow user to set block size before enabling device The capability of setting hw_block_size was added along with 9c1cd1b68 "target/user: Only support full command pass-through", though default setting override the user specified value during the enabling of device, which called by target_configure_device() to set block_size matching hw_block_size, result in user not able to set different block size other than default 512. This patch would use existing hw_block_size value if already set, otherwise it would be set to default value(512). Update: Fix the coding style issue. (Drop unnecessary re-export of dev->dev_attrib.block_size - nab) Signed-off-by: Sheng Yang Cc: Andy Grover Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/target') diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index d5477c0d730a..da187e635ea3 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -917,8 +917,10 @@ static int tcmu_configure_device(struct se_device *dev) if (ret) goto err_register; + /* User can set hw_block_size before enable the device */ + if (dev->dev_attrib.hw_block_size == 0) + dev->dev_attrib.hw_block_size = 512; /* Other attributes can be configured in userspace */ - dev->dev_attrib.hw_block_size = 512; dev->dev_attrib.hw_max_sectors = 128; dev->dev_attrib.hw_queue_depth = 128; -- cgit v1.2.3