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:
  bdi: Fix warnings in __mark_inode_dirty for /dev/zero and friends
  char: Mark /dev/zero and /dev/kmem as not capable of writeback
  bdi: Initialize noop_backing_dev_info properly
  cfq-iosched: fix a kernel OOPs when usb key is inserted
  block: fix blk_rq_map_kern bio direction flag
  cciss: freeing uninitialized data on error path
  • Loading branch information
Linus Torvalds committed Sep 22, 2010
2 parents 62f1b49 + 692ebd1 commit b68e9d4
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
return PTR_ERR(bio);

if (rq_data_dir(rq) == WRITE)
bio->bi_rw |= (1 << REQ_WRITE);
bio->bi_rw |= REQ_WRITE;

if (do_copy)
rq->cmd_flags |= REQ_COPY_USER;
Expand Down
16 changes: 13 additions & 3 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,20 @@ cfq_find_alloc_cfqg(struct cfq_data *cfqd, struct cgroup *cgroup, int create)
*/
atomic_set(&cfqg->ref, 1);

/* Add group onto cgroup list */
sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
cfq_blkiocg_add_blkio_group(blkcg, &cfqg->blkg, (void *)cfqd,
/*
* Add group onto cgroup list. It might happen that bdi->dev is
* not initiliazed yet. Initialize this new group without major
* and minor info and this info will be filled in once a new thread
* comes for IO. See code above.
*/
if (bdi->dev) {
sscanf(dev_name(bdi->dev), "%u:%u", &major, &minor);
cfq_blkiocg_add_blkio_group(blkcg, &cfqg->blkg, (void *)cfqd,
MKDEV(major, minor));
} else
cfq_blkiocg_add_blkio_group(blkcg, &cfqg->blkg, (void *)cfqd,
0);

cfqg->weight = blkcg_get_weight(blkcg, cfqg->blkg.dev);

/* Add group on cfqd list */
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -4792,7 +4792,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
clean4:
kfree(h->cmd_pool_bits);
/* Free up sg elements */
for (k = 0; k < h->nr_cmds; k++)
for (k-- ; k >= 0; k--)
kfree(h->scatter_list[k]);
kfree(h->scatter_list);
cciss_free_sg_chain_blocks(h->cmd_sg_list, h->nr_cmds);
Expand Down
3 changes: 2 additions & 1 deletion drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,11 @@ static const struct file_operations zero_fops = {
/*
* capabilities for /dev/zero
* - permits private mappings, "copies" are taken of the source of zeros
* - no writeback happens
*/
static struct backing_dev_info zero_bdi = {
.name = "char/mem",
.capabilities = BDI_CAP_MAP_COPY,
.capabilities = BDI_CAP_MAP_COPY | BDI_CAP_NO_ACCT_AND_WRITEBACK,
};

static const struct file_operations full_fops = {
Expand Down
4 changes: 3 additions & 1 deletion fs/char_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ struct backing_dev_info directly_mappable_cdev_bdi = {
#endif
/* permit direct mmap, for read, write or exec */
BDI_CAP_MAP_DIRECT |
BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP),
BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP |
/* no writeback happens */
BDI_CAP_NO_ACCT_AND_WRITEBACK),
};

static struct kobj_map *cdev_map;
Expand Down
23 changes: 21 additions & 2 deletions fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ struct wb_writeback_work {
#define CREATE_TRACE_POINTS
#include <trace/events/writeback.h>

#define inode_to_bdi(inode) ((inode)->i_mapping->backing_dev_info)

/*
* We don't actually have pdflush, but this one is exported though /proc...
*/
Expand All @@ -71,6 +69,27 @@ int writeback_in_progress(struct backing_dev_info *bdi)
return test_bit(BDI_writeback_running, &bdi->state);
}

static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
{
struct super_block *sb = inode->i_sb;
struct backing_dev_info *bdi = inode->i_mapping->backing_dev_info;

/*
* For inodes on standard filesystems, we use superblock's bdi. For
* inodes on virtual filesystems, we want to use inode mapping's bdi
* because they can possibly point to something useful (think about
* block_dev filesystem).
*/
if (sb->s_bdi && sb->s_bdi != &noop_backing_dev_info) {
/* Some device inodes could play dirty tricks. Catch them... */
WARN(bdi != sb->s_bdi && bdi_cap_writeback_dirty(bdi),
"Dirtiable inode bdi %s != sb bdi %s\n",
bdi->name, sb->s_bdi->name);
return sb->s_bdi;
}
return bdi;
}

static void bdi_queue_work(struct backing_dev_info *bdi,
struct wb_writeback_work *work)
{
Expand Down
2 changes: 2 additions & 0 deletions mm/backing-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ EXPORT_SYMBOL_GPL(default_backing_dev_info);

struct backing_dev_info noop_backing_dev_info = {
.name = "noop",
.capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
};
EXPORT_SYMBOL_GPL(noop_backing_dev_info);

Expand Down Expand Up @@ -243,6 +244,7 @@ static int __init default_bdi_init(void)
err = bdi_init(&default_backing_dev_info);
if (!err)
bdi_register(&default_backing_dev_info, NULL, "default");
err = bdi_init(&noop_backing_dev_info);

return err;
}
Expand Down

0 comments on commit b68e9d4

Please sign in to comment.