Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53699
b: refs/heads/master
c: 44ec954
h: refs/heads/master
i:
  53697: 79b7b7c
  53695: 1bb4f08
v: v3
  • Loading branch information
Alan Stern authored and James Bottomley committed Apr 17, 2007
1 parent 46935c4 commit 3ef7859
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1079a2d251f24a7d9e7576217f5f738bc4218337
refs/heads/master: 44ec95425c1d9dce6e4638c29e4362cfb44814e7
2 changes: 2 additions & 0 deletions trunk/block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,8 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);

q->sg_reserved_size = INT_MAX;

/*
* all done
*/
Expand Down
4 changes: 3 additions & 1 deletion trunk/block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ static int sg_set_timeout(request_queue_t *q, int __user *p)

static int sg_get_reserved_size(request_queue_t *q, int __user *p)
{
return put_user(q->sg_reserved_size, p);
unsigned val = min(q->sg_reserved_size, q->max_sectors << 9);

return put_user(val, p);
}

static int sg_set_reserved_size(request_queue_t *q, int __user *p)
Expand Down
13 changes: 11 additions & 2 deletions trunk/drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,8 @@ sg_ioctl(struct inode *inode, struct file *filp,
return result;
if (val < 0)
return -EINVAL;
val = min_t(int, val,
sdp->device->request_queue->max_sectors * 512);
if (val != sfp->reserve.bufflen) {
if (sg_res_in_use(sfp) || sfp->mmap_called)
return -EBUSY;
Expand All @@ -925,7 +927,8 @@ sg_ioctl(struct inode *inode, struct file *filp,
}
return 0;
case SG_GET_RESERVED_SIZE:
val = (int) sfp->reserve.bufflen;
val = min_t(int, sfp->reserve.bufflen,
sdp->device->request_queue->max_sectors * 512);
return put_user(val, ip);
case SG_SET_COMMAND_Q:
result = get_user(val, ip);
Expand Down Expand Up @@ -1061,6 +1064,9 @@ sg_ioctl(struct inode *inode, struct file *filp,
if (sdp->detached)
return -ENODEV;
return scsi_ioctl(sdp->device, cmd_in, p);
case BLKSECTGET:
return put_user(sdp->device->request_queue->max_sectors * 512,
ip);
default:
if (read_only)
return -EPERM; /* don't know so take safe approach */
Expand Down Expand Up @@ -2339,6 +2345,7 @@ sg_add_sfp(Sg_device * sdp, int dev)
{
Sg_fd *sfp;
unsigned long iflags;
int bufflen;

sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN);
if (!sfp)
Expand Down Expand Up @@ -2369,7 +2376,9 @@ sg_add_sfp(Sg_device * sdp, int dev)
if (unlikely(sg_big_buff != def_reserved_size))
sg_big_buff = def_reserved_size;

sg_build_reserve(sfp, sg_big_buff);
bufflen = min_t(int, sg_big_buff,
sdp->device->request_queue->max_sectors * 512);
sg_build_reserve(sfp, bufflen);
SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n",
sfp->reserve.bufflen, sfp->reserve.k_use_sg));
return sfp;
Expand Down

0 comments on commit 3ef7859

Please sign in to comment.