[PATCH] pass fmode_t to blkdev_put()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2008-02-22 20:40:24 -05:00
parent 511de73ff0
commit 9a1c354276
14 changed files with 38 additions and 38 deletions

View file

@ -2381,7 +2381,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
out_unclaim: out_unclaim:
bd_release(pd->bdev); bd_release(pd->bdev);
out_putdev: out_putdev:
blkdev_put(pd->bdev); blkdev_put(pd->bdev, FMODE_READ);
out: out:
return ret; return ret;
} }
@ -2399,7 +2399,7 @@ static void pkt_release_dev(struct pktcdvd_device *pd, int flush)
pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); pkt_set_speed(pd, MAX_SPEED, MAX_SPEED);
bd_release(pd->bdev); bd_release(pd->bdev);
blkdev_put(pd->bdev); blkdev_put(pd->bdev, FMODE_READ);
pkt_shrink_pktlist(pd); pkt_shrink_pktlist(pd);
} }
@ -2790,7 +2790,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
return 0; return 0;
out_mem: out_mem:
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
/* This is safe: open() is still holding a reference. */ /* This is safe: open() is still holding a reference. */
module_put(THIS_MODULE); module_put(THIS_MODULE);
return ret; return ret;
@ -2975,7 +2975,7 @@ static int pkt_remove_dev(dev_t pkt_dev)
pkt_debugfs_dev_remove(pd); pkt_debugfs_dev_remove(pd);
pkt_sysfs_dev_remove(pd); pkt_sysfs_dev_remove(pd);
blkdev_put(pd->bdev); blkdev_put(pd->bdev, FMODE_READ|FMODE_WRITE);
remove_proc_entry(pd->name, pkt_proc); remove_proc_entry(pd->name, pkt_proc);
DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name); DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name);

View file

@ -87,7 +87,7 @@ static int raw_open(struct inode *inode, struct file *filp)
out2: out2:
bd_release(bdev); bd_release(bdev);
out1: out1:
blkdev_put(bdev); blkdev_put(bdev, filp->f_mode);
out: out:
mutex_unlock(&raw_mutex); mutex_unlock(&raw_mutex);
return err; return err;
@ -112,7 +112,7 @@ static int raw_release(struct inode *inode, struct file *filp)
mutex_unlock(&raw_mutex); mutex_unlock(&raw_mutex);
bd_release(bdev); bd_release(bdev);
blkdev_put(bdev); blkdev_put(bdev, filp->f_mode);
return 0; return 0;
} }

View file

@ -357,7 +357,7 @@ static int open_dev(struct dm_dev_internal *d, dev_t dev,
return PTR_ERR(bdev); return PTR_ERR(bdev);
r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md)); r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md));
if (r) if (r)
blkdev_put(bdev); blkdev_put(bdev, d->dm_dev.mode);
else else
d->dm_dev.bdev = bdev; d->dm_dev.bdev = bdev;
return r; return r;
@ -372,7 +372,7 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)
return; return;
bd_release_from_disk(d->dm_dev.bdev, dm_disk(md)); bd_release_from_disk(d->dm_dev.bdev, dm_disk(md));
blkdev_put(d->dm_dev.bdev); blkdev_put(d->dm_dev.bdev, d->dm_dev.mode);
d->dm_dev.bdev = NULL; d->dm_dev.bdev = NULL;
} }

View file

@ -1520,7 +1520,7 @@ static int lock_rdev(mdk_rdev_t *rdev, dev_t dev, int shared)
if (err) { if (err) {
printk(KERN_ERR "md: could not bd_claim %s.\n", printk(KERN_ERR "md: could not bd_claim %s.\n",
bdevname(bdev, b)); bdevname(bdev, b));
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
return err; return err;
} }
if (!shared) if (!shared)
@ -1536,7 +1536,7 @@ static void unlock_rdev(mdk_rdev_t *rdev)
if (!bdev) if (!bdev)
MD_BUG(); MD_BUG();
bd_release(bdev); bd_release(bdev);
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
} }
void md_autodetect_dev(dev_t dev); void md_autodetect_dev(dev_t dev);

View file

@ -152,7 +152,7 @@ void dasd_destroy_partitions(struct dasd_block *block)
invalidate_partition(block->gdp, 0); invalidate_partition(block->gdp, 0);
/* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */ /* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ);
set_capacity(block->gdp, 0); set_capacity(block->gdp, 0);
} }

View file

@ -977,7 +977,7 @@ EXPORT_SYMBOL(bd_set_size);
static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags, static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags,
int for_part); int for_part);
static int __blkdev_put(struct block_device *bdev, int for_part); static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part);
/* /*
* bd_mutex locking: * bd_mutex locking:
@ -1095,7 +1095,7 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
bdev->bd_part = NULL; bdev->bd_part = NULL;
bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
if (bdev != bdev->bd_contains) if (bdev != bdev->bd_contains)
__blkdev_put(bdev->bd_contains, 1); __blkdev_put(bdev->bd_contains, file->f_mode, 1);
bdev->bd_contains = NULL; bdev->bd_contains = NULL;
out_unlock_bdev: out_unlock_bdev:
mutex_unlock(&bdev->bd_mutex); mutex_unlock(&bdev->bd_mutex);
@ -1163,11 +1163,11 @@ static int blkdev_open(struct inode * inode, struct file * filp)
if (!(res = bd_claim(bdev, filp))) if (!(res = bd_claim(bdev, filp)))
return 0; return 0;
blkdev_put(bdev); blkdev_put(bdev, filp->f_mode);
return res; return res;
} }
static int __blkdev_put(struct block_device *bdev, int for_part) static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
{ {
int ret = 0; int ret = 0;
struct gendisk *disk = bdev->bd_disk; struct gendisk *disk = bdev->bd_disk;
@ -1184,7 +1184,7 @@ static int __blkdev_put(struct block_device *bdev, int for_part)
} }
if (bdev->bd_contains == bdev) { if (bdev->bd_contains == bdev) {
if (disk->fops->release) if (disk->fops->release)
ret = disk->fops->release(disk, 0); ret = disk->fops->release(disk, mode);
} }
if (!bdev->bd_openers) { if (!bdev->bd_openers) {
struct module *owner = disk->fops->owner; struct module *owner = disk->fops->owner;
@ -1203,13 +1203,13 @@ static int __blkdev_put(struct block_device *bdev, int for_part)
mutex_unlock(&bdev->bd_mutex); mutex_unlock(&bdev->bd_mutex);
bdput(bdev); bdput(bdev);
if (victim) if (victim)
__blkdev_put(victim, 1); __blkdev_put(victim, mode, 1);
return ret; return ret;
} }
int blkdev_put(struct block_device *bdev) int blkdev_put(struct block_device *bdev, fmode_t mode)
{ {
return __blkdev_put(bdev, 0); return __blkdev_put(bdev, mode, 0);
} }
EXPORT_SYMBOL(blkdev_put); EXPORT_SYMBOL(blkdev_put);
@ -1218,7 +1218,7 @@ static int blkdev_close(struct inode * inode, struct file * filp)
struct block_device *bdev = I_BDEV(filp->f_mapping->host); struct block_device *bdev = I_BDEV(filp->f_mapping->host);
if (bdev->bd_holder == filp) if (bdev->bd_holder == filp)
bd_release(bdev); bd_release(bdev);
return blkdev_put(bdev); return blkdev_put(bdev, filp->f_mode);
} }
static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg) static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
@ -1343,7 +1343,7 @@ struct block_device *open_bdev_excl(const char *path, int flags, void *holder)
return bdev; return bdev;
blkdev_put: blkdev_put:
blkdev_put(bdev); blkdev_put(bdev, mode);
return ERR_PTR(error); return ERR_PTR(error);
} }
@ -1359,7 +1359,7 @@ EXPORT_SYMBOL(open_bdev_excl);
void close_bdev_excl(struct block_device *bdev) void close_bdev_excl(struct block_device *bdev)
{ {
bd_release(bdev); bd_release(bdev);
blkdev_put(bdev); blkdev_put(bdev, 0); /* move up in the next patches */
} }
EXPORT_SYMBOL(close_bdev_excl); EXPORT_SYMBOL(close_bdev_excl);

View file

@ -347,7 +347,7 @@ fail:
static int ext3_blkdev_put(struct block_device *bdev) static int ext3_blkdev_put(struct block_device *bdev)
{ {
bd_release(bdev); bd_release(bdev);
return blkdev_put(bdev); return blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
} }
static int ext3_blkdev_remove(struct ext3_sb_info *sbi) static int ext3_blkdev_remove(struct ext3_sb_info *sbi)
@ -2066,7 +2066,7 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
if (bd_claim(bdev, sb)) { if (bd_claim(bdev, sb)) {
printk(KERN_ERR printk(KERN_ERR
"EXT3: failed to claim external journal device.\n"); "EXT3: failed to claim external journal device.\n");
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
return NULL; return NULL;
} }

View file

@ -399,7 +399,7 @@ fail:
static int ext4_blkdev_put(struct block_device *bdev) static int ext4_blkdev_put(struct block_device *bdev)
{ {
bd_release(bdev); bd_release(bdev);
return blkdev_put(bdev); return blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
} }
static int ext4_blkdev_remove(struct ext4_sb_info *sbi) static int ext4_blkdev_remove(struct ext4_sb_info *sbi)
@ -2553,7 +2553,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
if (bd_claim(bdev, sb)) { if (bd_claim(bdev, sb)) {
printk(KERN_ERR printk(KERN_ERR
"EXT4: failed to claim external journal device.\n"); "EXT4: failed to claim external journal device.\n");
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
return NULL; return NULL;
} }

View file

@ -1168,7 +1168,7 @@ journal_found:
bd_release(bdev); bd_release(bdev);
close: /* close external log device */ close: /* close external log device */
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
free: /* free log descriptor */ free: /* free log descriptor */
mutex_unlock(&jfs_log_mutex); mutex_unlock(&jfs_log_mutex);
@ -1514,7 +1514,7 @@ int lmLogClose(struct super_block *sb)
rc = lmLogShutdown(log); rc = lmLogShutdown(log);
bd_release(bdev); bd_release(bdev);
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
kfree(log); kfree(log);

View file

@ -976,7 +976,7 @@ static void o2hb_region_release(struct config_item *item)
} }
if (reg->hr_bdev) if (reg->hr_bdev)
blkdev_put(reg->hr_bdev); blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE);
if (reg->hr_slots) if (reg->hr_slots)
kfree(reg->hr_slots); kfree(reg->hr_slots);
@ -1358,7 +1358,7 @@ out:
iput(inode); iput(inode);
if (ret < 0) { if (ret < 0) {
if (reg->hr_bdev) { if (reg->hr_bdev) {
blkdev_put(reg->hr_bdev); blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE);
reg->hr_bdev = NULL; reg->hr_bdev = NULL;
} }
} }

View file

@ -488,7 +488,7 @@ void register_disk(struct gendisk *disk)
err = blkdev_get(bdev, FMODE_READ, 0); err = blkdev_get(bdev, FMODE_READ, 0);
if (err < 0) if (err < 0)
goto exit; goto exit;
blkdev_put(bdev); blkdev_put(bdev, FMODE_READ);
exit: exit:
/* announce disk after possible partitions are created */ /* announce disk after possible partitions are created */

View file

@ -2575,7 +2575,7 @@ static int release_journal_dev(struct super_block *super,
if (journal->j_dev_bd != NULL) { if (journal->j_dev_bd != NULL) {
if (journal->j_dev_bd->bd_dev != super->s_dev) if (journal->j_dev_bd->bd_dev != super->s_dev)
bd_release(journal->j_dev_bd); bd_release(journal->j_dev_bd);
result = blkdev_put(journal->j_dev_bd); result = blkdev_put(journal->j_dev_bd, 0); /* move up */
journal->j_dev_bd = NULL; journal->j_dev_bd = NULL;
} }
@ -2618,7 +2618,7 @@ static int journal_init_dev(struct super_block *super,
} else if (jdev != super->s_dev) { } else if (jdev != super->s_dev) {
result = bd_claim(journal->j_dev_bd, journal); result = bd_claim(journal->j_dev_bd, journal);
if (result) { if (result) {
blkdev_put(journal->j_dev_bd); blkdev_put(journal->j_dev_bd, blkdev_mode);
return result; return result;
} }

View file

@ -1722,7 +1722,7 @@ extern int blkdev_driver_ioctl(struct inode *inode, struct file *file,
unsigned long arg); unsigned long arg);
extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
extern int blkdev_get(struct block_device *, fmode_t, unsigned); extern int blkdev_get(struct block_device *, fmode_t, unsigned);
extern int blkdev_put(struct block_device *); extern int blkdev_put(struct block_device *, fmode_t);
extern int bd_claim(struct block_device *, void *); extern int bd_claim(struct block_device *, void *);
extern void bd_release(struct block_device *); extern void bd_release(struct block_device *);
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS

View file

@ -178,7 +178,7 @@ static int swsusp_swap_check(void) /* This is called before saving image */
res = set_blocksize(resume_bdev, PAGE_SIZE); res = set_blocksize(resume_bdev, PAGE_SIZE);
if (res < 0) if (res < 0)
blkdev_put(resume_bdev); blkdev_put(resume_bdev, FMODE_WRITE);
return res; return res;
} }
@ -574,7 +574,7 @@ int swsusp_read(unsigned int *flags_p)
error = load_image(&handle, &snapshot, header->pages - 1); error = load_image(&handle, &snapshot, header->pages - 1);
release_swap_reader(&handle); release_swap_reader(&handle);
blkdev_put(resume_bdev); blkdev_put(resume_bdev, FMODE_READ);
if (!error) if (!error)
pr_debug("PM: Image successfully loaded\n"); pr_debug("PM: Image successfully loaded\n");
@ -609,7 +609,7 @@ int swsusp_check(void)
return -EINVAL; return -EINVAL;
} }
if (error) if (error)
blkdev_put(resume_bdev); blkdev_put(resume_bdev, FMODE_READ);
else else
pr_debug("PM: Signature found, resuming\n"); pr_debug("PM: Signature found, resuming\n");
} else { } else {
@ -633,7 +633,7 @@ void swsusp_close(void)
return; return;
} }
blkdev_put(resume_bdev); blkdev_put(resume_bdev, 0); /* move up */
} }
static int swsusp_header_init(void) static int swsusp_header_init(void)