Commit b83c1ac7 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (4/14) resync

added bdev_read_only() - analog of is_read_only() using block_device.
Almost all callers of is_read_only() converted.
parent 23f2ac44
...@@ -221,3 +221,10 @@ anything from oops to silent memory corruption. ...@@ -221,3 +221,10 @@ anything from oops to silent memory corruption.
FS_NOMOUNT is gone. If you use it - just set MS_NOUSER in flags FS_NOMOUNT is gone. If you use it - just set MS_NOUSER in flags
(see rootfs for one kind of solution and bdev/socket/pipe for another). (see rootfs for one kind of solution and bdev/socket/pipe for another).
---
[recommended]
Use bdev_read_only(bdev) instead of is_read_only(kdev). The latter
is still alive, but only because of the mess in drivers/s390/block/dasd.c.
As soon as it gets fixed is_read_only() will die.
...@@ -236,7 +236,7 @@ int blk_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long arg) ...@@ -236,7 +236,7 @@ int blk_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long arg)
set_device_ro(dev, intval); set_device_ro(dev, intval);
return 0; return 0;
case BLKROGET: case BLKROGET:
intval = (is_read_only(dev) != 0); intval = (bdev_read_only(bdev) != 0);
return put_user(intval, (int *)(arg)); return put_user(intval, (int *)(arg));
case BLKRASET: case BLKRASET:
......
...@@ -1196,6 +1196,11 @@ int is_read_only(kdev_t dev) ...@@ -1196,6 +1196,11 @@ int is_read_only(kdev_t dev)
return ro_bits[major][minor >> 5] & (1 << (minor & 31)); return ro_bits[major][minor >> 5] & (1 << (minor & 31));
} }
int bdev_read_only(struct block_device *bdev)
{
return bdev && is_read_only(to_kdev_t(bdev->bd_dev));
}
void set_device_ro(kdev_t dev,int flag) void set_device_ro(kdev_t dev,int flag)
{ {
int minor,major; int minor,major;
...@@ -1765,7 +1770,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]) ...@@ -1765,7 +1770,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head * bhs[])
} }
} }
if ((rw & WRITE) && is_read_only(to_kdev_t(bhs[0]->b_bdev->bd_dev))) { if ((rw & WRITE) && bdev_read_only(bhs[0]->b_bdev)) {
printk(KERN_NOTICE "Can't write to read-only device %s\n", printk(KERN_NOTICE "Can't write to read-only device %s\n",
bdevname(bhs[0]->b_bdev)); bdevname(bhs[0]->b_bdev));
goto sorry; goto sorry;
......
...@@ -679,7 +679,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -679,7 +679,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
get_file(file); get_file(file);
if (IS_RDONLY (inode) || is_read_only(to_kdev_t(lo_device->bd_dev)) if (IS_RDONLY (inode) || bdev_read_only(lo_device)
|| !(lo_file->f_mode & FMODE_WRITE)) || !(lo_file->f_mode & FMODE_WRITE))
lo_flags |= LO_FLAGS_READ_ONLY; lo_flags |= LO_FLAGS_READ_ONLY;
......
...@@ -344,7 +344,7 @@ void ll_rw_kio(int rw, struct kiobuf *kio, struct block_device *bdev, sector_t s ...@@ -344,7 +344,7 @@ void ll_rw_kio(int rw, struct kiobuf *kio, struct block_device *bdev, sector_t s
kdev_t dev = to_kdev_t(bdev->bd_dev); kdev_t dev = to_kdev_t(bdev->bd_dev);
err = 0; err = 0;
if ((rw & WRITE) && is_read_only(dev)) { if ((rw & WRITE) && bdev_read_only(bdev)) {
printk("ll_rw_bio: WRITE to ro device %s\n", kdevname(dev)); printk("ll_rw_bio: WRITE to ro device %s\n", kdevname(dev));
err = -EPERM; err = -EPERM;
goto out; goto out;
......
...@@ -1400,7 +1400,7 @@ static int ext3_load_journal(struct super_block * sb, ...@@ -1400,7 +1400,7 @@ static int ext3_load_journal(struct super_block * sb,
int err = 0; int err = 0;
int really_read_only; int really_read_only;
really_read_only = is_read_only(sb->s_dev); really_read_only = bdev_read_only(sb->s_bdev);
/* /*
* Are we loading a blank journal or performing recovery after a * Are we loading a blank journal or performing recovery after a
......
...@@ -1707,7 +1707,7 @@ static int journal_read(struct super_block *p_s_sb) { ...@@ -1707,7 +1707,7 @@ static int journal_read(struct super_block *p_s_sb) {
goto start_log_replay; goto start_log_replay;
} }
if (continue_replay && is_read_only(p_s_sb->s_dev)) { if (continue_replay && bdev_read_only(p_s_sb->s_bdev)) {
printk("clm-2076: device is readonly, unable to replay log\n") ; printk("clm-2076: device is readonly, unable to replay log\n") ;
return -1 ; return -1 ;
} }
...@@ -1796,7 +1796,7 @@ static int journal_read(struct super_block *p_s_sb) { ...@@ -1796,7 +1796,7 @@ static int journal_read(struct super_block *p_s_sb) {
printk("reiserfs: replayed %d transactions in %lu seconds\n", replay_count, printk("reiserfs: replayed %d transactions in %lu seconds\n", replay_count,
CURRENT_TIME - start) ; CURRENT_TIME - start) ;
} }
if (!is_read_only(p_s_sb->s_dev) && if (!bdev_read_only(p_s_sb->s_bdev) &&
_update_journal_header_block(p_s_sb, SB_JOURNAL(p_s_sb)->j_start, _update_journal_header_block(p_s_sb, SB_JOURNAL(p_s_sb)->j_start,
SB_JOURNAL(p_s_sb)->j_last_flush_trans_id)) SB_JOURNAL(p_s_sb)->j_last_flush_trans_id))
{ {
......
...@@ -1063,7 +1063,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -1063,7 +1063,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
if (replay_only (s)) if (replay_only (s))
goto error; goto error;
if (is_read_only(s->s_dev) && !(s->s_flags & MS_RDONLY)) { if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
printk("clm-7000: Detected readonly device, marking FS readonly\n") ; printk("clm-7000: Detected readonly device, marking FS readonly\n") ;
s->s_flags |= MS_RDONLY ; s->s_flags |= MS_RDONLY ;
} }
......
...@@ -367,7 +367,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data) ...@@ -367,7 +367,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data)
{ {
int retval; int retval;
if (!(flags & MS_RDONLY) && !kdev_none(sb->s_dev) && is_read_only(sb->s_dev)) if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev))
return -EACCES; return -EACCES;
/*flags |= MS_RDONLY;*/ /*flags |= MS_RDONLY;*/
if (flags & MS_RDONLY) if (flags & MS_RDONLY)
...@@ -485,7 +485,7 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type, ...@@ -485,7 +485,7 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
goto out; goto out;
check_disk_change(dev); check_disk_change(dev);
error = -EACCES; error = -EACCES;
if (!(flags & MS_RDONLY) && is_read_only(dev)) if (!(flags & MS_RDONLY) && bdev_read_only(bdev))
goto out1; goto out1;
error = bd_claim(bdev, fs_type); error = bd_claim(bdev, fs_type);
if (error) if (error)
......
...@@ -1220,6 +1220,7 @@ extern int submit_bh(int, struct buffer_head *); ...@@ -1220,6 +1220,7 @@ extern int submit_bh(int, struct buffer_head *);
struct bio; struct bio;
extern int submit_bio(int, struct bio *); extern int submit_bio(int, struct bio *);
extern int is_read_only(kdev_t); extern int is_read_only(kdev_t);
extern int bdev_read_only(struct block_device *);
extern int set_blocksize(struct block_device *, int); extern int set_blocksize(struct block_device *, int);
extern int sb_set_blocksize(struct super_block *, int); extern int sb_set_blocksize(struct super_block *, int);
extern int sb_min_blocksize(struct super_block *, int); extern int sb_min_blocksize(struct super_block *, int);
......
...@@ -326,6 +326,7 @@ EXPORT_SYMBOL(tty_std_termios); ...@@ -326,6 +326,7 @@ EXPORT_SYMBOL(tty_std_termios);
EXPORT_SYMBOL(blk_size); EXPORT_SYMBOL(blk_size);
EXPORT_SYMBOL(blk_dev); EXPORT_SYMBOL(blk_dev);
EXPORT_SYMBOL(is_read_only); EXPORT_SYMBOL(is_read_only);
EXPORT_SYMBOL(bdev_read_only);
EXPORT_SYMBOL(set_device_ro); EXPORT_SYMBOL(set_device_ro);
EXPORT_SYMBOL(bmap); EXPORT_SYMBOL(bmap);
EXPORT_SYMBOL(devfs_register_partitions); EXPORT_SYMBOL(devfs_register_partitions);
......
...@@ -2178,7 +2178,7 @@ generic_file_write(struct file *file, const char *buf, ...@@ -2178,7 +2178,7 @@ generic_file_write(struct file *file, const char *buf,
if (unlikely(pos + count > inode->i_sb->s_maxbytes)) if (unlikely(pos + count > inode->i_sb->s_maxbytes))
count = inode->i_sb->s_maxbytes - pos; count = inode->i_sb->s_maxbytes - pos;
} else { } else {
if (is_read_only(inode->i_rdev)) { if (bdev_read_only(inode->i_bdev)) {
err = -EPERM; err = -EPERM;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment