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

[PATCH] (8/14) resync

get_super() split in two functions - get_super(bdev) and
user_get_super(dev_t).  Callers that used get_super() to get superblock
by (dev_t) syscall argument switched to the latter; the rest had
block_device in question and switched to passing it.
parent 334c8b07
...@@ -107,9 +107,7 @@ static int hpux_ustat(dev_t dev, struct hpux_ustat *ubuf) ...@@ -107,9 +107,7 @@ static int hpux_ustat(dev_t dev, struct hpux_ustat *ubuf)
struct statfs sbuf; struct statfs sbuf;
int err = -EINVAL; int err = -EINVAL;
lock_kernel(); s = user_get_super(dev);
s = get_super(to_kdev_t(dev));
unlock_kernel();
if (s == NULL) if (s == NULL)
goto out; goto out;
err = vfs_statfs(s, &sbuf); err = vfs_statfs(s, &sbuf);
......
...@@ -232,7 +232,7 @@ int fsync_super(struct super_block *sb) ...@@ -232,7 +232,7 @@ int fsync_super(struct super_block *sb)
*/ */
int fsync_bdev(struct block_device *bdev) int fsync_bdev(struct block_device *bdev)
{ {
struct super_block *sb = get_super(to_kdev_t(bdev->bd_dev)); struct super_block *sb = get_super(bdev);
if (sb) { if (sb) {
int res = fsync_super(sb); int res = fsync_super(sb);
drop_super(sb); drop_super(sb);
......
...@@ -332,7 +332,7 @@ int invalidate_device(kdev_t dev, int do_sync) ...@@ -332,7 +332,7 @@ int invalidate_device(kdev_t dev, int do_sync)
fsync_bdev(bdev); fsync_bdev(bdev);
res = 0; res = 0;
sb = get_super(dev); sb = get_super(bdev);
if (sb) { if (sb) {
/* /*
* no need to lock the super, get_super holds the * no need to lock the super, get_super holds the
......
...@@ -105,14 +105,14 @@ static struct super_block *resolve_dev(const char *path) ...@@ -105,14 +105,14 @@ static struct super_block *resolve_dev(const char *path)
int ret; int ret;
mode_t mode; mode_t mode;
struct nameidata nd; struct nameidata nd;
kdev_t dev; struct block_device *bdev;
struct super_block *sb; struct super_block *sb;
ret = user_path_walk(path, &nd); ret = user_path_walk(path, &nd);
if (ret) if (ret)
goto out; goto out;
dev = nd.dentry->d_inode->i_rdev; bdev = nd.dentry->d_inode->i_bdev;
mode = nd.dentry->d_inode->i_mode; mode = nd.dentry->d_inode->i_mode;
path_release(&nd); path_release(&nd);
...@@ -120,7 +120,7 @@ static struct super_block *resolve_dev(const char *path) ...@@ -120,7 +120,7 @@ static struct super_block *resolve_dev(const char *path)
if (!S_ISBLK(mode)) if (!S_ISBLK(mode))
goto out; goto out;
ret = -ENODEV; ret = -ENODEV;
sb = get_super(dev); sb = get_super(bdev);
if (!sb) if (!sb)
goto out; goto out;
return sb; return sb;
......
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
* *
*/ */
static struct super_block *procinfo_prologue( kdev_t dev ) static struct super_block *procinfo_prologue(dev_t dev)
{ {
struct super_block *result; struct super_block *result;
/* get super-block by device */ /* get super-block by device */
result = get_super( dev ); result = user_get_super(dev);
if( result != NULL ) { if( result != NULL ) {
if( !reiserfs_is_super( result ) ) { if( !reiserfs_is_super( result ) ) {
printk( KERN_DEBUG "reiserfs: procfs-52: " printk( KERN_DEBUG "reiserfs: procfs-52: "
...@@ -78,7 +78,7 @@ int reiserfs_version_in_proc( char *buffer, char **start, off_t offset, ...@@ -78,7 +78,7 @@ int reiserfs_version_in_proc( char *buffer, char **start, off_t offset,
struct super_block *sb; struct super_block *sb;
char *format; char *format;
sb = procinfo_prologue( to_kdev_t((int)data) ); sb = procinfo_prologue((dev_t)data);
if( sb == NULL ) if( sb == NULL )
return -ENOENT; return -ENOENT;
if ( REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6) ) { if ( REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6) ) {
...@@ -136,7 +136,7 @@ int reiserfs_super_in_proc( char *buffer, char **start, off_t offset, ...@@ -136,7 +136,7 @@ int reiserfs_super_in_proc( char *buffer, char **start, off_t offset,
struct reiserfs_sb_info *r; struct reiserfs_sb_info *r;
int len = 0; int len = 0;
sb = procinfo_prologue( to_kdev_t((int)data) ); sb = procinfo_prologue((dev_t)data);
if( sb == NULL ) if( sb == NULL )
return -ENOENT; return -ENOENT;
r = REISERFS_SB(sb); r = REISERFS_SB(sb);
...@@ -216,7 +216,7 @@ int reiserfs_per_level_in_proc( char *buffer, char **start, off_t offset, ...@@ -216,7 +216,7 @@ int reiserfs_per_level_in_proc( char *buffer, char **start, off_t offset,
int len = 0; int len = 0;
int level; int level;
sb = procinfo_prologue( to_kdev_t((int)data) ); sb = procinfo_prologue((dev_t)data);
if( sb == NULL ) if( sb == NULL )
return -ENOENT; return -ENOENT;
r = REISERFS_SB(sb); r = REISERFS_SB(sb);
...@@ -295,7 +295,7 @@ int reiserfs_bitmap_in_proc( char *buffer, char **start, off_t offset, ...@@ -295,7 +295,7 @@ int reiserfs_bitmap_in_proc( char *buffer, char **start, off_t offset,
struct reiserfs_sb_info *r; struct reiserfs_sb_info *r;
int len = 0; int len = 0;
sb = procinfo_prologue( to_kdev_t((int)data) ); sb = procinfo_prologue((dev_t)data);
if( sb == NULL ) if( sb == NULL )
return -ENOENT; return -ENOENT;
r = REISERFS_SB(sb); r = REISERFS_SB(sb);
...@@ -336,7 +336,7 @@ int reiserfs_on_disk_super_in_proc( char *buffer, char **start, off_t offset, ...@@ -336,7 +336,7 @@ int reiserfs_on_disk_super_in_proc( char *buffer, char **start, off_t offset,
int hash_code; int hash_code;
int len = 0; int len = 0;
sb = procinfo_prologue( to_kdev_t((int)data) ); sb = procinfo_prologue((dev_t)data);
if( sb == NULL ) if( sb == NULL )
return -ENOENT; return -ENOENT;
sb_info = REISERFS_SB(sb); sb_info = REISERFS_SB(sb);
...@@ -393,7 +393,7 @@ int reiserfs_oidmap_in_proc( char *buffer, char **start, off_t offset, ...@@ -393,7 +393,7 @@ int reiserfs_oidmap_in_proc( char *buffer, char **start, off_t offset,
int len = 0; int len = 0;
int exact; int exact;
sb = procinfo_prologue( to_kdev_t((int)data) ); sb = procinfo_prologue((dev_t)data);
if( sb == NULL ) if( sb == NULL )
return -ENOENT; return -ENOENT;
sb_info = REISERFS_SB(sb); sb_info = REISERFS_SB(sb);
...@@ -445,7 +445,7 @@ int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset, ...@@ -445,7 +445,7 @@ int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset,
struct journal_params *jp; struct journal_params *jp;
int len = 0; int len = 0;
sb = procinfo_prologue( to_kdev_t((int)data) ); sb = procinfo_prologue((dev_t)data);
if( sb == NULL ) if( sb == NULL )
return -ENOENT; return -ENOENT;
r = REISERFS_SB(sb); r = REISERFS_SB(sb);
......
...@@ -249,20 +249,6 @@ struct super_block *sget(struct file_system_type *type, ...@@ -249,20 +249,6 @@ struct super_block *sget(struct file_system_type *type,
struct vfsmount *alloc_vfsmnt(char *name); struct vfsmount *alloc_vfsmnt(char *name);
void free_vfsmnt(struct vfsmount *mnt); void free_vfsmnt(struct vfsmount *mnt);
static inline struct super_block * find_super(kdev_t dev)
{
struct list_head *p;
list_for_each(p, &super_blocks) {
struct super_block * s = sb_entry(p);
if (kdev_same(s->s_dev, dev)) {
s->s_count++;
return s;
}
}
return NULL;
}
void drop_super(struct super_block *sb) void drop_super(struct super_block *sb)
{ {
up_read(&sb->s_umount); up_read(&sb->s_umount);
...@@ -309,26 +295,50 @@ void sync_supers(void) ...@@ -309,26 +295,50 @@ void sync_supers(void)
* Scans the superblock list and finds the superblock of the file system * Scans the superblock list and finds the superblock of the file system
* mounted on the device given. %NULL is returned if no match is found. * mounted on the device given. %NULL is returned if no match is found.
*/ */
struct super_block * get_super(kdev_t dev)
{
struct super_block * s;
if (kdev_none(dev)) struct super_block * get_super(struct block_device *bdev)
{
struct list_head *p;
if (!bdev)
return NULL; return NULL;
rescan:
spin_lock(&sb_lock);
list_for_each(p, &super_blocks) {
struct super_block *s = sb_entry(p);
if (s->s_bdev == bdev) {
s->s_count++;
spin_unlock(&sb_lock);
down_read(&s->s_umount);
if (s->s_root)
return s;
drop_super(s);
goto rescan;
}
}
spin_unlock(&sb_lock);
return NULL;
}
struct super_block * user_get_super(dev_t dev)
{
struct list_head *p;
while (1) { rescan:
spin_lock(&sb_lock); spin_lock(&sb_lock);
s = find_super(dev); list_for_each(p, &super_blocks) {
spin_unlock(&sb_lock); struct super_block *s = sb_entry(p);
if (!s) if (kdev_t_to_nr(s->s_dev) == dev) {
break; s->s_count++;
down_read(&s->s_umount); spin_unlock(&sb_lock);
if (s->s_root) down_read(&s->s_umount);
break; if (s->s_root)
drop_super(s); return s;
drop_super(s);
goto rescan;
}
} }
return s; spin_unlock(&sb_lock);
return NULL;
} }
asmlinkage long sys_ustat(dev_t dev, struct ustat * ubuf) asmlinkage long sys_ustat(dev_t dev, struct ustat * ubuf)
...@@ -338,7 +348,7 @@ asmlinkage long sys_ustat(dev_t dev, struct ustat * ubuf) ...@@ -338,7 +348,7 @@ asmlinkage long sys_ustat(dev_t dev, struct ustat * ubuf)
struct statfs sbuf; struct statfs sbuf;
int err = -EINVAL; int err = -EINVAL;
s = get_super(to_kdev_t(dev)); s = user_get_super(dev);
if (s == NULL) if (s == NULL)
goto out; goto out;
err = vfs_statfs(s, &sbuf); err = vfs_statfs(s, &sbuf);
......
...@@ -1255,7 +1255,8 @@ extern int vfs_lstat(char *, struct kstat *); ...@@ -1255,7 +1255,8 @@ extern int vfs_lstat(char *, struct kstat *);
extern int vfs_fstat(unsigned int, struct kstat *); extern int vfs_fstat(unsigned int, struct kstat *);
extern struct file_system_type *get_fs_type(const char *name); extern struct file_system_type *get_fs_type(const char *name);
extern struct super_block *get_super(kdev_t); extern struct super_block *get_super(struct block_device *);
extern struct super_block *user_get_super(dev_t);
extern void drop_super(struct super_block *sb); extern void drop_super(struct super_block *sb);
extern int dcache_dir_open(struct inode *, struct file *); extern int dcache_dir_open(struct inode *, struct file *);
......
...@@ -131,6 +131,7 @@ EXPORT_SYMBOL(kmap_pte); ...@@ -131,6 +131,7 @@ EXPORT_SYMBOL(kmap_pte);
EXPORT_SYMBOL(def_blk_fops); EXPORT_SYMBOL(def_blk_fops);
EXPORT_SYMBOL(update_atime); EXPORT_SYMBOL(update_atime);
EXPORT_SYMBOL(get_fs_type); EXPORT_SYMBOL(get_fs_type);
EXPORT_SYMBOL(user_get_super);
EXPORT_SYMBOL(get_super); EXPORT_SYMBOL(get_super);
EXPORT_SYMBOL(drop_super); EXPORT_SYMBOL(drop_super);
EXPORT_SYMBOL(getname); EXPORT_SYMBOL(getname);
......
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