Commit d2346963 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  quota: Pass information that quota is stored in system file to userspace
  ext2: protect inode changes in the SETVERSION and SETFLAGS ioctls
  jbd: Issue cache flush after checkpointing
parents 4a7cbb56 46fe44ce
...@@ -77,10 +77,11 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -77,10 +77,11 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
flags = flags & EXT2_FL_USER_MODIFIABLE; flags = flags & EXT2_FL_USER_MODIFIABLE;
flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE; flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
ei->i_flags = flags; ei->i_flags = flags;
mutex_unlock(&inode->i_mutex);
ext2_set_inode_flags(inode); ext2_set_inode_flags(inode);
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
mutex_unlock(&inode->i_mutex);
mark_inode_dirty(inode); mark_inode_dirty(inode);
setflags_out: setflags_out:
mnt_drop_write_file(filp); mnt_drop_write_file(filp);
...@@ -88,20 +89,29 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -88,20 +89,29 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
} }
case EXT2_IOC_GETVERSION: case EXT2_IOC_GETVERSION:
return put_user(inode->i_generation, (int __user *) arg); return put_user(inode->i_generation, (int __user *) arg);
case EXT2_IOC_SETVERSION: case EXT2_IOC_SETVERSION: {
__u32 generation;
if (!inode_owner_or_capable(inode)) if (!inode_owner_or_capable(inode))
return -EPERM; return -EPERM;
ret = mnt_want_write_file(filp); ret = mnt_want_write_file(filp);
if (ret) if (ret)
return ret; return ret;
if (get_user(inode->i_generation, (int __user *) arg)) { if (get_user(generation, (int __user *) arg)) {
ret = -EFAULT; ret = -EFAULT;
} else { goto setversion_out;
}
mutex_lock(&inode->i_mutex);
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
inode->i_generation = generation;
mutex_unlock(&inode->i_mutex);
mark_inode_dirty(inode); mark_inode_dirty(inode);
} setversion_out:
mnt_drop_write_file(filp); mnt_drop_write_file(filp);
return ret; return ret;
}
case EXT2_IOC_GETRSVSZ: case EXT2_IOC_GETRSVSZ:
if (test_opt(inode->i_sb, RESERVATION) if (test_opt(inode->i_sb, RESERVATION)
&& S_ISREG(inode->i_mode) && S_ISREG(inode->i_mode)
......
...@@ -453,8 +453,6 @@ int log_do_checkpoint(journal_t *journal) ...@@ -453,8 +453,6 @@ int log_do_checkpoint(journal_t *journal)
* *
* Return <0 on error, 0 on success, 1 if there was nothing to clean up. * Return <0 on error, 0 on success, 1 if there was nothing to clean up.
* *
* Called with the journal lock held.
*
* This is the only part of the journaling code which really needs to be * This is the only part of the journaling code which really needs to be
* aware of transaction aborts. Checkpointing involves writing to the * aware of transaction aborts. Checkpointing involves writing to the
* main filesystem area rather than to the journal, so it can proceed * main filesystem area rather than to the journal, so it can proceed
...@@ -472,13 +470,14 @@ int cleanup_journal_tail(journal_t *journal) ...@@ -472,13 +470,14 @@ int cleanup_journal_tail(journal_t *journal)
if (is_journal_aborted(journal)) if (is_journal_aborted(journal))
return 1; return 1;
/* OK, work out the oldest transaction remaining in the log, and /*
* OK, work out the oldest transaction remaining in the log, and
* the log block it starts at. * the log block it starts at.
* *
* If the log is now empty, we need to work out which is the * If the log is now empty, we need to work out which is the
* next transaction ID we will write, and where it will * next transaction ID we will write, and where it will
* start. */ * start.
*/
spin_lock(&journal->j_state_lock); spin_lock(&journal->j_state_lock);
spin_lock(&journal->j_list_lock); spin_lock(&journal->j_list_lock);
transaction = journal->j_checkpoint_transactions; transaction = journal->j_checkpoint_transactions;
...@@ -504,7 +503,25 @@ int cleanup_journal_tail(journal_t *journal) ...@@ -504,7 +503,25 @@ int cleanup_journal_tail(journal_t *journal)
spin_unlock(&journal->j_state_lock); spin_unlock(&journal->j_state_lock);
return 1; return 1;
} }
spin_unlock(&journal->j_state_lock);
/*
* We need to make sure that any blocks that were recently written out
* --- perhaps by log_do_checkpoint() --- are flushed out before we
* drop the transactions from the journal. It's unlikely this will be
* necessary, especially with an appropriately sized journal, but we
* need this to guarantee correctness. Fortunately
* cleanup_journal_tail() doesn't get called all that often.
*/
if (journal->j_flags & JFS_BARRIER)
blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL);
spin_lock(&journal->j_state_lock);
if (!tid_gt(first_tid, journal->j_tail_sequence)) {
spin_unlock(&journal->j_state_lock);
/* Someone else cleaned up journal so return 0 */
return 0;
}
/* OK, update the superblock to recover the freed space. /* OK, update the superblock to recover the freed space.
* Physical blocks come first: have we wrapped beyond the end of * Physical blocks come first: have we wrapped beyond the end of
* the log? */ * the log? */
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/jbd.h> #include <linux/jbd.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/blkdev.h>
#endif #endif
/* /*
...@@ -263,6 +264,9 @@ int journal_recover(journal_t *journal) ...@@ -263,6 +264,9 @@ int journal_recover(journal_t *journal)
err2 = sync_blockdev(journal->j_fs_dev); err2 = sync_blockdev(journal->j_fs_dev);
if (!err) if (!err)
err = err2; err = err2;
/* Flush disk caches to get replayed data on the permanent storage */
if (journal->j_flags & JFS_BARRIER)
blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL);
return err; return err;
} }
......
...@@ -2125,6 +2125,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id, ...@@ -2125,6 +2125,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
mutex_unlock(&dqopt->dqio_mutex); mutex_unlock(&dqopt->dqio_mutex);
goto out_file_init; goto out_file_init;
} }
if (dqopt->flags & DQUOT_QUOTA_SYS_FILE)
dqopt->info[type].dqi_flags |= DQF_SYS_FILE;
mutex_unlock(&dqopt->dqio_mutex); mutex_unlock(&dqopt->dqio_mutex);
spin_lock(&dq_state_lock); spin_lock(&dq_state_lock);
dqopt->flags |= dquot_state_flag(flags, type); dqopt->flags |= dquot_state_flag(flags, type);
...@@ -2464,7 +2466,7 @@ int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) ...@@ -2464,7 +2466,7 @@ int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
spin_lock(&dq_data_lock); spin_lock(&dq_data_lock);
ii->dqi_bgrace = mi->dqi_bgrace; ii->dqi_bgrace = mi->dqi_bgrace;
ii->dqi_igrace = mi->dqi_igrace; ii->dqi_igrace = mi->dqi_igrace;
ii->dqi_flags = mi->dqi_flags & DQF_MASK; ii->dqi_flags = mi->dqi_flags & DQF_GETINFO_MASK;
ii->dqi_valid = IIF_ALL; ii->dqi_valid = IIF_ALL;
spin_unlock(&dq_data_lock); spin_unlock(&dq_data_lock);
mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
...@@ -2490,8 +2492,8 @@ int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) ...@@ -2490,8 +2492,8 @@ int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
if (ii->dqi_valid & IIF_IGRACE) if (ii->dqi_valid & IIF_IGRACE)
mi->dqi_igrace = ii->dqi_igrace; mi->dqi_igrace = ii->dqi_igrace;
if (ii->dqi_valid & IIF_FLAGS) if (ii->dqi_valid & IIF_FLAGS)
mi->dqi_flags = (mi->dqi_flags & ~DQF_MASK) | mi->dqi_flags = (mi->dqi_flags & ~DQF_SETINFO_MASK) |
(ii->dqi_flags & DQF_MASK); (ii->dqi_flags & DQF_SETINFO_MASK);
spin_unlock(&dq_data_lock); spin_unlock(&dq_data_lock);
mark_info_dirty(sb, type); mark_info_dirty(sb, type);
/* Force write to disk */ /* Force write to disk */
......
...@@ -230,7 +230,11 @@ struct mem_dqinfo { ...@@ -230,7 +230,11 @@ struct mem_dqinfo {
struct super_block; struct super_block;
#define DQF_MASK 0xffff /* Mask for format specific flags */ #define DQF_MASK 0xffff /* Mask for format specific flags */
#define DQF_INFO_DIRTY_B 16 #define DQF_GETINFO_MASK 0x1ffff /* Mask for flags passed to userspace */
#define DQF_SETINFO_MASK 0xffff /* Mask for flags modifiable from userspace */
#define DQF_SYS_FILE_B 16
#define DQF_SYS_FILE (1 << DQF_SYS_FILE_B) /* Quota file stored as system file */
#define DQF_INFO_DIRTY_B 31
#define DQF_INFO_DIRTY (1 << DQF_INFO_DIRTY_B) /* Is info dirty? */ #define DQF_INFO_DIRTY (1 << DQF_INFO_DIRTY_B) /* Is info dirty? */
extern void mark_info_dirty(struct super_block *sb, int type); extern void mark_info_dirty(struct super_block *sb, int type);
......
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