Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
Browse files Browse the repository at this point in the history
* 'for-linus' of git://git.kernel.dk/linux-2.6-block:
  block: remove blk_queue_tag_depth() and blk_queue_tag_queue()
  block: remove unused ->busy part of the block queue tag map
  bio: fix __bio_copy_iov() handling of bio->bv_len
  bio: fix bio_copy_kern() handling of bio->bv_len
  block: submit_bh() inadvertently discards barrier flag on a sync write
  block: clean up cmdfilter sysfs interface
  block: rename blk_scsi_cmd_filter to blk_cmd_filter
  sg: restore command permission for TYPE_SCANNER
  block: move cmdfilter from gendisk to request_queue
  • Loading branch information
Linus Torvalds committed Aug 27, 2008
2 parents e472233 + 5168c47 commit 0559bc8
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 225 deletions.
2 changes: 2 additions & 0 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)

q->sg_reserved_size = INT_MAX;

blk_set_cmd_filter_defaults(&q->cmd_filter);

/*
* all done
*/
Expand Down
6 changes: 2 additions & 4 deletions block/blk-tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ static int __blk_free_tags(struct blk_queue_tag *bqt)

retval = atomic_dec_and_test(&bqt->refcnt);
if (retval) {
BUG_ON(bqt->busy);
BUG_ON(find_first_bit(bqt->tag_map, bqt->max_depth) <
bqt->max_depth);

kfree(bqt->tag_index);
bqt->tag_index = NULL;
Expand Down Expand Up @@ -147,7 +148,6 @@ static struct blk_queue_tag *__blk_queue_init_tags(struct request_queue *q,
if (init_tag_map(q, tags, depth))
goto fail;

tags->busy = 0;
atomic_set(&tags->refcnt, 1);
return tags;
fail:
Expand Down Expand Up @@ -313,7 +313,6 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq)
* unlock memory barrier semantics.
*/
clear_bit_unlock(tag, bqt->tag_map);
bqt->busy--;
}
EXPORT_SYMBOL(blk_queue_end_tag);

Expand Down Expand Up @@ -368,7 +367,6 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq)
bqt->tag_index[tag] = rq;
blkdev_dequeue_request(rq);
list_add(&rq->queuelist, &q->tag_busy_list);
bqt->busy++;
return 0;
}
EXPORT_SYMBOL(blk_queue_start_tag);
Expand Down
44 changes: 11 additions & 33 deletions block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ struct bsg_device {
char name[BUS_ID_SIZE];
int max_queue;
unsigned long flags;
struct blk_scsi_cmd_filter *cmd_filter;
mode_t *f_mode;
};

enum {
Expand Down Expand Up @@ -174,7 +172,8 @@ static int bsg_io_schedule(struct bsg_device *bd)
}

static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
struct sg_io_v4 *hdr, struct bsg_device *bd)
struct sg_io_v4 *hdr, struct bsg_device *bd,
int has_write_perm)
{
if (hdr->request_len > BLK_MAX_CDB) {
rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
Expand All @@ -187,8 +186,7 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
return -EFAULT;

if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
if (blk_cmd_filter_verify_command(bd->cmd_filter, rq->cmd,
bd->f_mode))
if (blk_verify_command(&q->cmd_filter, rq->cmd, has_write_perm))
return -EPERM;
} else if (!capable(CAP_SYS_RAWIO))
return -EPERM;
Expand Down Expand Up @@ -244,7 +242,7 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)
* map sg_io_v4 to a request.
*/
static struct request *
bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, int has_write_perm)
{
struct request_queue *q = bd->queue;
struct request *rq, *next_rq = NULL;
Expand All @@ -266,7 +264,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
rq = blk_get_request(q, rw, GFP_KERNEL);
if (!rq)
return ERR_PTR(-ENOMEM);
ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd);
ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd, has_write_perm);
if (ret)
goto out;

Expand Down Expand Up @@ -568,25 +566,6 @@ static inline void bsg_set_block(struct bsg_device *bd, struct file *file)
set_bit(BSG_F_BLOCK, &bd->flags);
}

static void bsg_set_cmd_filter(struct bsg_device *bd,
struct file *file)
{
struct inode *inode;
struct gendisk *disk;

if (!file)
return;

inode = file->f_dentry->d_inode;
if (!inode)
return;

disk = inode->i_bdev->bd_disk;

bd->cmd_filter = &disk->cmd_filter;
bd->f_mode = &file->f_mode;
}

/*
* Check if the error is a "real" error that we should return.
*/
Expand All @@ -608,7 +587,6 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
dprintk("%s: read %Zd bytes\n", bd->name, count);

bsg_set_block(bd, file);
bsg_set_cmd_filter(bd, file);

bytes_read = 0;
ret = __bsg_read(buf, count, bd, NULL, &bytes_read);
Expand All @@ -621,7 +599,7 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
}

static int __bsg_write(struct bsg_device *bd, const char __user *buf,
size_t count, ssize_t *bytes_written)
size_t count, ssize_t *bytes_written, int has_write_perm)
{
struct bsg_command *bc;
struct request *rq;
Expand Down Expand Up @@ -652,7 +630,7 @@ static int __bsg_write(struct bsg_device *bd, const char __user *buf,
/*
* get a request, fill in the blanks, and add to request queue
*/
rq = bsg_map_hdr(bd, &bc->hdr);
rq = bsg_map_hdr(bd, &bc->hdr, has_write_perm);
if (IS_ERR(rq)) {
ret = PTR_ERR(rq);
rq = NULL;
Expand Down Expand Up @@ -683,10 +661,11 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
dprintk("%s: write %Zd bytes\n", bd->name, count);

bsg_set_block(bd, file);
bsg_set_cmd_filter(bd, file);

bytes_written = 0;
ret = __bsg_write(bd, buf, count, &bytes_written);
ret = __bsg_write(bd, buf, count, &bytes_written,
file->f_mode & FMODE_WRITE);

*ppos = bytes_written;

/*
Expand Down Expand Up @@ -792,7 +771,6 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
bd->queue = rq;

bsg_set_block(bd, file);
bsg_set_cmd_filter(bd, file);

atomic_set(&bd->ref_count, 1);
mutex_lock(&bsg_mutex);
Expand Down Expand Up @@ -943,7 +921,7 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (copy_from_user(&hdr, uarg, sizeof(hdr)))
return -EFAULT;

rq = bsg_map_hdr(bd, &hdr);
rq = bsg_map_hdr(bd, &hdr, file->f_mode & FMODE_WRITE);
if (IS_ERR(rq))
return PTR_ERR(rq);

Expand Down
Loading

0 comments on commit 0559bc8

Please sign in to comment.