]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 14 Jul 2008 20:15:14 +0000 (13:15 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 14 Jul 2008 20:15:14 +0000 (13:15 -0700)
* 'for-linus' of git://git.kernel.dk/linux-2.6-block: (37 commits)
  splice: fix generic_file_splice_read() race with page invalidation
  ramfs: enable splice write
  drivers/block/pktcdvd.c: avoid useless memset
  cdrom: revert commit 22a9189 (cdrom: use kmalloced buffers instead of buffers on stack)
  scsi: sr avoids useless buffer allocation
  block: blk_rq_map_kern uses the bounce buffers for stack buffers
  block: add blk_queue_update_dma_pad
  DAC960: push down BKL
  pktcdvd: push BKL down into driver
  paride: push ioctl down into driver
  block: use get_unaligned_* helpers
  block: extend queue_flag bitops
  block: request_module(): use format string
  Add bvec_merge_data to handle stacked devices and ->merge_bvec()
  block: integrity flags can't use bit ops on unsigned short
  cmdfilter: extend default read filter
  sg: fix odd style (extra parenthesis) introduced by cmd filter patch
  block: add bounce support to blk_rq_map_user_iov
  cfq-iosched: get rid of enable_idle being unused warning
  allow userspace to modify scsi command filter on per device basis
  ...

1  2 
block/bsg.c
drivers/md/raid5.c

diff --combined block/bsg.c
index 54d617f7df3e03b3aa02def2473b03ad66a5d39b,439940c3a1ff01c1d40e0f00a0baacc223cdc70a..93e757d7174b8b7a5ff6aeaee124915bfda5ccf7
@@@ -44,11 -44,12 +44,12 @@@ 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 {
        BSG_F_BLOCK             = 1,
-       BSG_F_WRITE_PERM        = 2,
  };
  
  #define BSG_DEFAULT_CMDS      64
@@@ -172,7 -173,7 +173,7 @@@ unlock
  }
  
  static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
-                               struct sg_io_v4 *hdr, int has_write_perm)
+                               struct sg_io_v4 *hdr, struct bsg_device *bd)
  {
        if (hdr->request_len > BLK_MAX_CDB) {
                rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
                return -EFAULT;
  
        if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
-               if (blk_verify_command(rq->cmd, has_write_perm))
+               if (blk_cmd_filter_verify_command(bd->cmd_filter, rq->cmd,
+                                                bd->f_mode))
                        return -EPERM;
        } else if (!capable(CAP_SYS_RAWIO))
                return -EPERM;
@@@ -263,8 -265,7 +265,7 @@@ bsg_map_hdr(struct bsg_device *bd, stru
        rq = blk_get_request(q, rw, GFP_KERNEL);
        if (!rq)
                return ERR_PTR(-ENOMEM);
-       ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, test_bit(BSG_F_WRITE_PERM,
-                                                      &bd->flags));
+       ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd);
        if (ret)
                goto out;
  
@@@ -566,12 -567,23 +567,23 @@@ static inline void bsg_set_block(struc
                set_bit(BSG_F_BLOCK, &bd->flags);
  }
  
- static inline void bsg_set_write_perm(struct bsg_device *bd, struct file *file)
+ static void bsg_set_cmd_filter(struct bsg_device *bd,
+                          struct file *file)
  {
-       if (file->f_mode & FMODE_WRITE)
-               set_bit(BSG_F_WRITE_PERM, &bd->flags);
-       else
-               clear_bit(BSG_F_WRITE_PERM, &bd->flags);
+       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;
  }
  
  /*
@@@ -595,6 -607,8 +607,8 @@@ bsg_read(struct file *file, char __use
        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);
        *ppos = bytes_read;
@@@ -668,7 -682,7 +682,7 @@@ bsg_write(struct file *file, const cha
        dprintk("%s: write %Zd bytes\n", bd->name, count);
  
        bsg_set_block(bd, file);
-       bsg_set_write_perm(bd, file);
+       bsg_set_cmd_filter(bd, file);
  
        bytes_written = 0;
        ret = __bsg_write(bd, buf, count, &bytes_written);
@@@ -709,12 -723,11 +723,12 @@@ static void bsg_kref_release_function(s
  {
        struct bsg_class_device *bcd =
                container_of(kref, struct bsg_class_device, ref);
 +      struct device *parent = bcd->parent;
  
        if (bcd->release)
                bcd->release(bcd->parent);
  
 -      put_device(bcd->parent);
 +      put_device(parent);
  }
  
  static int bsg_put_device(struct bsg_device *bd)
@@@ -772,7 -785,9 +786,9 @@@ static struct bsg_device *bsg_add_devic
        }
  
        bd->queue = rq;
        bsg_set_block(bd, file);
+       bsg_set_cmd_filter(bd, file);
  
        atomic_set(&bd->ref_count, 1);
        mutex_lock(&bsg_mutex);
diff --combined drivers/md/raid5.c
index 3b27df52456b510219c4f3f22dfb2c644ff3845c,9b00675dc64f8e6955bb7f7ce0bc55545ddeb7ce..9ce7154845c67eb4acffc441462667b9a152f468
@@@ -2017,7 -2017,12 +2017,7 @@@ static int __handle_issuing_new_read_re
                         */
                        s->uptodate++;
                        return 0; /* uptodate + compute == disks */
 -              } else if ((s->uptodate < disks - 1) &&
 -                      test_bit(R5_Insync, &dev->flags)) {
 -                      /* Note: we hold off compute operations while checks are
 -                       * in flight, but we still prefer 'compute' over 'read'
 -                       * hence we only read if (uptodate < * disks-1)
 -                       */
 +              } else if (test_bit(R5_Insync, &dev->flags)) {
                        set_bit(R5_LOCKED, &dev->flags);
                        set_bit(R5_Wantread, &dev->flags);
                        if (!test_and_set_bit(STRIPE_OP_IO, &sh->ops.pending))
@@@ -3314,15 -3319,17 +3314,17 @@@ static int raid5_congested(void *data, 
  /* We want read requests to align with chunks where possible,
   * but write requests don't need to.
   */
- static int raid5_mergeable_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *biovec)
+ static int raid5_mergeable_bvec(struct request_queue *q,
+                               struct bvec_merge_data *bvm,
+                               struct bio_vec *biovec)
  {
        mddev_t *mddev = q->queuedata;
-       sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev);
+       sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
        int max;
        unsigned int chunk_sectors = mddev->chunk_size >> 9;
-       unsigned int bio_sectors = bio->bi_size >> 9;
+       unsigned int bio_sectors = bvm->bi_size >> 9;
  
-       if (bio_data_dir(bio) == WRITE)
+       if ((bvm->bi_rw & 1) == WRITE)
                return biovec->bv_len; /* always allow writes to be mergeable */
  
        max =  (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;