Commit b88f83d5 authored by Andrew Morton's avatar Andrew Morton Committed by Jaroslav Kysela

[PATCH] provide a default super_block_operations

A little cleanup suggested by Chris Mason or Al Viro.

Quite a number of codepaths are testing whether a superblock has a
non-null ->s_op pointer.  We can remove all those by making sure that
all superblocks have a valid ->s_op.
parent 654107b9
...@@ -219,11 +219,10 @@ int fsync_super(struct super_block *sb) ...@@ -219,11 +219,10 @@ int fsync_super(struct super_block *sb)
sync_inodes_sb(sb, 0); sync_inodes_sb(sb, 0);
DQUOT_SYNC(sb); DQUOT_SYNC(sb);
lock_super(sb); lock_super(sb);
if (sb->s_dirt && sb->s_op && sb->s_op->write_super) if (sb->s_dirt && sb->s_op->write_super)
sb->s_op->write_super(sb); sb->s_op->write_super(sb);
if (sb->s_op && sb->s_op->sync_fs) { if (sb->s_op->sync_fs)
sb->s_op->sync_fs(sb, 1); sb->s_op->sync_fs(sb, 1);
}
unlock_super(sb); unlock_super(sb);
sync_blockdev(sb->s_bdev); sync_blockdev(sb->s_bdev);
sync_inodes_sb(sb, 1); sync_inodes_sb(sb, 1);
...@@ -281,7 +280,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync) ...@@ -281,7 +280,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
/* sync the superblock to buffers */ /* sync the superblock to buffers */
sb = inode->i_sb; sb = inode->i_sb;
lock_super(sb); lock_super(sb);
if (sb->s_op && sb->s_op->write_super) if (sb->s_op->write_super)
sb->s_op->write_super(sb); sb->s_op->write_super(sb);
unlock_super(sb); unlock_super(sb);
......
...@@ -57,7 +57,7 @@ void __mark_inode_dirty(struct inode *inode, int flags) ...@@ -57,7 +57,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
* dirty the inode itself * dirty the inode itself
*/ */
if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) { if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) {
if (sb->s_op && sb->s_op->dirty_inode) if (sb->s_op->dirty_inode)
sb->s_op->dirty_inode(inode); sb->s_op->dirty_inode(inode);
} }
...@@ -101,8 +101,7 @@ void __mark_inode_dirty(struct inode *inode, int flags) ...@@ -101,8 +101,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
static void write_inode(struct inode *inode, int sync) static void write_inode(struct inode *inode, int sync)
{ {
if (inode->i_sb->s_op && inode->i_sb->s_op->write_inode && if (inode->i_sb->s_op->write_inode && !is_bad_inode(inode))
!is_bad_inode(inode))
inode->i_sb->s_op->write_inode(inode, sync); inode->i_sb->s_op->write_inode(inode, sync);
} }
......
...@@ -225,7 +225,7 @@ void clear_inode(struct inode *inode) ...@@ -225,7 +225,7 @@ void clear_inode(struct inode *inode)
BUG(); BUG();
wait_on_inode(inode); wait_on_inode(inode);
DQUOT_DROP(inode); DQUOT_DROP(inode);
if (inode->i_sb && inode->i_sb->s_op && inode->i_sb->s_op->clear_inode) if (inode->i_sb && inode->i_sb->s_op->clear_inode)
inode->i_sb->s_op->clear_inode(inode); inode->i_sb->s_op->clear_inode(inode);
if (inode->i_bdev) if (inode->i_bdev)
bd_forget(inode); bd_forget(inode);
...@@ -937,7 +937,7 @@ void generic_delete_inode(struct inode *inode) ...@@ -937,7 +937,7 @@ void generic_delete_inode(struct inode *inode)
security_inode_delete(inode); security_inode_delete(inode);
if (op && op->delete_inode) { if (op->delete_inode) {
void (*delete)(struct inode *) = op->delete_inode; void (*delete)(struct inode *) = op->delete_inode;
if (!is_bad_inode(inode)) if (!is_bad_inode(inode))
DQUOT_INIT(inode); DQUOT_INIT(inode);
......
...@@ -29,7 +29,7 @@ int vfs_statfs(struct super_block *sb, struct statfs *buf) ...@@ -29,7 +29,7 @@ int vfs_statfs(struct super_block *sb, struct statfs *buf)
if (sb) { if (sb) {
retval = -ENOSYS; retval = -ENOSYS;
if (sb->s_op && sb->s_op->statfs) { if (sb->s_op->statfs) {
memset(buf, 0, sizeof(struct statfs)); memset(buf, 0, sizeof(struct statfs));
retval = security_sb_statfs(sb); retval = security_sb_statfs(sb);
if (retval) if (retval)
......
...@@ -49,6 +49,8 @@ spinlock_t sb_lock = SPIN_LOCK_UNLOCKED; ...@@ -49,6 +49,8 @@ spinlock_t sb_lock = SPIN_LOCK_UNLOCKED;
static struct super_block *alloc_super(void) static struct super_block *alloc_super(void)
{ {
struct super_block *s = kmalloc(sizeof(struct super_block), GFP_USER); struct super_block *s = kmalloc(sizeof(struct super_block), GFP_USER);
static struct super_operations default_op;
if (s) { if (s) {
memset(s, 0, sizeof(struct super_block)); memset(s, 0, sizeof(struct super_block));
if (security_sb_alloc(s)) { if (security_sb_alloc(s)) {
...@@ -72,6 +74,7 @@ static struct super_block *alloc_super(void) ...@@ -72,6 +74,7 @@ static struct super_block *alloc_super(void)
s->s_maxbytes = MAX_NON_LFS; s->s_maxbytes = MAX_NON_LFS;
s->dq_op = sb_dquot_ops; s->dq_op = sb_dquot_ops;
s->s_qcop = sb_quotactl_ops; s->s_qcop = sb_quotactl_ops;
s->s_op = &default_op;
} }
out: out:
return s; return s;
...@@ -186,14 +189,13 @@ void generic_shutdown_super(struct super_block *sb) ...@@ -186,14 +189,13 @@ void generic_shutdown_super(struct super_block *sb)
sb->s_flags &= ~MS_ACTIVE; sb->s_flags &= ~MS_ACTIVE;
/* bad name - it should be evict_inodes() */ /* bad name - it should be evict_inodes() */
invalidate_inodes(sb); invalidate_inodes(sb);
if (sop) {
if (sop->write_super && sb->s_dirt) if (sop->write_super && sb->s_dirt)
sop->write_super(sb); sop->write_super(sb);
if (sop->sync_fs) if (sop->sync_fs)
sop->sync_fs(sb, 1); sop->sync_fs(sb, 1);
if (sop->put_super) if (sop->put_super)
sop->put_super(sb); sop->put_super(sb);
}
/* Forget any remaining inodes */ /* Forget any remaining inodes */
if (invalidate_inodes(sb)) { if (invalidate_inodes(sb)) {
...@@ -268,7 +270,7 @@ void drop_super(struct super_block *sb) ...@@ -268,7 +270,7 @@ void drop_super(struct super_block *sb)
static inline void write_super(struct super_block *sb) static inline void write_super(struct super_block *sb)
{ {
lock_super(sb); lock_super(sb);
if (sb->s_op && sb->s_root && sb->s_dirt) if (sb->s_root && sb->s_dirt)
if (sb->s_op->write_super) if (sb->s_op->write_super)
sb->s_op->write_super(sb); sb->s_op->write_super(sb);
unlock_super(sb); unlock_super(sb);
...@@ -309,8 +311,6 @@ void sync_filesystems(int wait) ...@@ -309,8 +311,6 @@ void sync_filesystems(int wait)
spin_lock(&sb_lock); spin_lock(&sb_lock);
for (sb = sb_entry(super_blocks.next); sb != sb_entry(&super_blocks); for (sb = sb_entry(super_blocks.next); sb != sb_entry(&super_blocks);
sb = sb_entry(sb->s_list.next)) { sb = sb_entry(sb->s_list.next)) {
if (!sb->s_op)
continue;
if (!sb->s_op->sync_fs); if (!sb->s_op->sync_fs);
continue; continue;
if (sb->s_flags & MS_RDONLY) if (sb->s_flags & MS_RDONLY)
...@@ -438,7 +438,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data) ...@@ -438,7 +438,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data)
if ((flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY)) if ((flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY))
if (!fs_may_remount_ro(sb)) if (!fs_may_remount_ro(sb))
return -EBUSY; return -EBUSY;
if (sb->s_op && sb->s_op->remount_fs) { if (sb->s_op->remount_fs) {
lock_super(sb); lock_super(sb);
retval = sb->s_op->remount_fs(sb, &flags, data); retval = sb->s_op->remount_fs(sb, &flags, data);
unlock_super(sb); unlock_super(sb);
......
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