Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: replace the fmode_t argument to ->sg_io_fn with a simple bool

Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/r/20230608110258.189493-21-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
1991299e 2e80089c

+9 -7
+1 -1
block/bsg-lib.c
··· 26 26 }; 27 27 28 28 static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr, 29 - fmode_t mode, unsigned int timeout) 29 + bool open_for_write, unsigned int timeout) 30 30 { 31 31 struct bsg_job *job; 32 32 struct request *rq;
+5 -3
block/bsg.c
··· 54 54 return max_t(unsigned int, timeout, BLK_MIN_SG_TIMEOUT); 55 55 } 56 56 57 - static int bsg_sg_io(struct bsg_device *bd, fmode_t mode, void __user *uarg) 57 + static int bsg_sg_io(struct bsg_device *bd, bool open_for_write, 58 + void __user *uarg) 58 59 { 59 60 struct sg_io_v4 hdr; 60 61 int ret; ··· 64 63 return -EFAULT; 65 64 if (hdr.guard != 'Q') 66 65 return -EINVAL; 67 - ret = bd->sg_io_fn(bd->queue, &hdr, mode, bsg_timeout(bd, &hdr)); 66 + ret = bd->sg_io_fn(bd->queue, &hdr, open_for_write, 67 + bsg_timeout(bd, &hdr)); 68 68 if (!ret && copy_to_user(uarg, &hdr, sizeof(hdr))) 69 69 return -EFAULT; 70 70 return ret; ··· 148 146 case SG_EMULATED_HOST: 149 147 return put_user(1, intp); 150 148 case SG_IO: 151 - return bsg_sg_io(bd, file->f_mode, uarg); 149 + return bsg_sg_io(bd, file->f_mode & FMODE_WRITE, uarg); 152 150 case SCSI_IOCTL_SEND_COMMAND: 153 151 pr_warn_ratelimited("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n", 154 152 current->comm);
+2 -2
drivers/scsi/scsi_bsg.c
··· 10 10 #define uptr64(val) ((void __user *)(uintptr_t)(val)) 11 11 12 12 static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr, 13 - fmode_t mode, unsigned int timeout) 13 + bool open_for_write, unsigned int timeout) 14 14 { 15 15 struct scsi_cmnd *scmd; 16 16 struct request *rq; ··· 42 42 if (copy_from_user(scmd->cmnd, uptr64(hdr->request), scmd->cmd_len)) 43 43 goto out_put_request; 44 44 ret = -EPERM; 45 - if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE)) 45 + if (!scsi_cmd_allowed(scmd->cmnd, open_for_write)) 46 46 goto out_put_request; 47 47 48 48 ret = 0;
+1 -1
include/linux/bsg.h
··· 9 9 struct request_queue; 10 10 11 11 typedef int (bsg_sg_io_fn)(struct request_queue *, struct sg_io_v4 *hdr, 12 - fmode_t mode, unsigned int timeout); 12 + bool open_for_write, unsigned int timeout); 13 13 14 14 struct bsg_device *bsg_register_queue(struct request_queue *q, 15 15 struct device *parent, const char *name,