From: Yuping Luo Date: Wed, 26 Oct 2011 02:13:10 +0000 (-0700) Subject: usb: gadget: mass_storage: support multi-luns with different logic block size X-Git-Tag: v3.3-rc1~153^2~28^2~40 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=144974e7f9e32b53b02f6c8632be45d8f43d6ab5;p=pandora-kernel.git usb: gadget: mass_storage: support multi-luns with different logic block size With Peiyu's patch "gadget: mass_storage: adapt logic block size to bound block devices" (http://www.spinics.net/lists/linux-usb/msg50791.html), now mass storage can adjust logic block size dynamically based on real devices. Then there is one issue caused by it, if two luns have different logic block size, mass storage can't work. Let's check the current software flow: 1. get_next_command(): call received_cbw(); 2. received_cbw(): update common->lun = cbw->Lun, but common->curlen is not updated; 3. do_scsi_command(): in READ_X and WRITE_X commands, common->data_size_from_cmnd is updated by common->curlun->blkbits; 4. check_command(): update common->curlun according to common->lun As you can see, the step 3 uses wrong common->curlun, then wrong common->curlun->blkbits. If the two luns have same blkbits, there isn't issue. Otherwise, both will fail. This patch moves the common->curlun update to step 1, then make sure step 3 gets right blkbits and data_size_from_cmnd. Cc: Peiyu Li Signed-off-by: YuPing Luo Signed-off-by: Barry Song Acked-by: Alan Stern Acked-by: Michal Nazarewicz Signed-off-by: Felipe Balbi --- Reading git-diff-tree failed