Re: [PATCH] [SCSI] arcmsr: &/| confusion in arcmsr_build_ccb()

From: Torsten Kaiser
Date: Sat Jan 01 2011 - 12:28:51 EST


On Sat, Jan 1, 2011 at 6:08 PM, Matthew Wilcox <matthew@xxxxxx> wrote:
> On Sat, Jan 01, 2011 at 05:45:11PM +0100, roel kluin wrote:
>> The WRITE_{6,10,12} are defined numbers, so the branch was always taken.
>
> You're right, but even this will basically always set the write flag,
> since some bits will be set the same, even for reads.  Eg:
>
> #define READ_10               0x28
> #define WRITE_10              0x2a
>
> It should instead be:
>
>> +     if (pcmd->cmnd[0] == WRITE_6 || pcmd->cmnd[0] == WRITE_10 ||
>> +                     pcmd->cmnd[0] == WRITE_12 ){
>
> That will of course miss other commands which do writes, such as UNMAP
> and WRITE_32.  So we should do it properly:
>
>        if (pcmd->sc_data_direction == DMA_TO_DEVICE)
>                arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE;
>

<http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=ae52e7f09ff509df11cd408eabe90132b6be1231;hp=f034260db330bb3ffc815fcb682b1c84aca09591#patch2>
@@ -1034,10 +1075,10 @@ static int arcmsr_build_ccb(struct
AdapterControlBlock *acb,
}
arcmsr_cdb->sgcount = (uint8_t)cdb_sgcount;
arcmsr_cdb->DataLength = scsi_bufflen(pcmd);
+ arcmsr_cdb->msgPages = arccdbsize/0x100 + (arccdbsize % 0x100 ? 1 : 0);
if ( arccdbsize > 256)
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE;
- }
- if (pcmd->sc_data_direction == DMA_TO_DEVICE ) {
+ if (pcmd->cmnd[0]|WRITE_6 || pcmd->cmnd[0] | WRITE_10 ||
pcmd->cmnd[0]|WRITE_12) {
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE;
ccb->ccb_flags |= CCB_FLAG_WRITE;
}

Until June 2010 it was that way...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/