Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147826
b: refs/heads/master
c: 864d7c4
h: refs/heads/master
v: v3
  • Loading branch information
npiggin@suse.de authored and Al Viro committed Jun 12, 2009
1 parent 8a404c9 commit 4aade00
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 96029c4e09ccbd73a6d0ed2b29e80bf2586ad7ef
refs/heads/master: 864d7c4c068f23642efe91b33be3a84afe5f71e0
38 changes: 38 additions & 0 deletions trunk/fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,44 @@ int fs_may_remount_ro(struct super_block *sb)
return 0;
}

/**
* mark_files_ro - mark all files read-only
* @sb: superblock in question
*
* All files are marked read-only. We don't care about pending
* delete files so this should be used in 'force' mode only.
*/
void mark_files_ro(struct super_block *sb)
{
struct file *f;

retry:
file_list_lock();
list_for_each_entry(f, &sb->s_files, f_u.fu_list) {
struct vfsmount *mnt;
if (!S_ISREG(f->f_path.dentry->d_inode->i_mode))
continue;
if (!file_count(f))
continue;
if (!(f->f_mode & FMODE_WRITE))
continue;
f->f_mode &= ~FMODE_WRITE;
if (file_check_writeable(f) != 0)
continue;
file_release_write(f);
mnt = mntget(f->f_path.mnt);
file_list_unlock();
/*
* This can sleep, so we can't hold
* the file_list_lock() spinlock.
*/
mnt_drop_write(mnt);
mntput(mnt);
goto retry;
}
file_list_unlock();
}

void __init files_init(unsigned long mempages)
{
int n;
Expand Down
5 changes: 5 additions & 0 deletions trunk/fs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ extern void __init mnt_init(void);
* fs_struct.c
*/
extern void chroot_fs_refs(struct path *, struct path *);

/*
* file_table.c
*/
extern void mark_files_ro(struct super_block *);
39 changes: 0 additions & 39 deletions trunk/fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,45 +615,6 @@ SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
return err;
}

/**
* mark_files_ro - mark all files read-only
* @sb: superblock in question
*
* All files are marked read-only. We don't care about pending
* delete files so this should be used in 'force' mode only.
*/

static void mark_files_ro(struct super_block *sb)
{
struct file *f;

retry:
file_list_lock();
list_for_each_entry(f, &sb->s_files, f_u.fu_list) {
struct vfsmount *mnt;
if (!S_ISREG(f->f_path.dentry->d_inode->i_mode))
continue;
if (!file_count(f))
continue;
if (!(f->f_mode & FMODE_WRITE))
continue;
f->f_mode &= ~FMODE_WRITE;
if (file_check_writeable(f) != 0)
continue;
file_release_write(f);
mnt = mntget(f->f_path.mnt);
file_list_unlock();
/*
* This can sleep, so we can't hold
* the file_list_lock() spinlock.
*/
mnt_drop_write(mnt);
mntput(mnt);
goto retry;
}
file_list_unlock();
}

/**
* do_remount_sb - asks filesystem to change mount options.
* @sb: superblock in question
Expand Down

0 comments on commit 4aade00

Please sign in to comment.