Skip to content

Commit 67e6682

Browse files
author
Dave Kleikamp
committed
JFS: Make sure special inode data is written after journal is flushed
This patch makes sure that data that we tried to flush before the journal was completely written actually gets pushed to disk. To avoid duplicating code, moved common code to write_special_inodes(). Signed-off-by: Dave Kleikamp <[email protected]>
1 parent 29a424f commit 67e6682

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

fs/jfs/jfs_logmgr.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ static struct lmStat {
208208
} lmStat;
209209
#endif
210210

211+
static void write_special_inodes(struct jfs_log *log,
212+
int (*writer)(struct address_space *))
213+
{
214+
struct jfs_sb_info *sbi;
215+
216+
list_for_each_entry(sbi, &log->sb_list, log_list) {
217+
writer(sbi->ipbmap->i_mapping);
218+
writer(sbi->ipimap->i_mapping);
219+
writer(sbi->direct_inode->i_mapping);
220+
}
221+
}
211222

212223
/*
213224
* NAME: lmLog()
@@ -935,22 +946,13 @@ static int lmLogSync(struct jfs_log * log, int hard_sync)
935946
struct lrd lrd;
936947
int lsn;
937948
struct logsyncblk *lp;
938-
struct jfs_sb_info *sbi;
939949
unsigned long flags;
940950

941951
/* push dirty metapages out to disk */
942952
if (hard_sync)
943-
list_for_each_entry(sbi, &log->sb_list, log_list) {
944-
filemap_fdatawrite(sbi->ipbmap->i_mapping);
945-
filemap_fdatawrite(sbi->ipimap->i_mapping);
946-
filemap_fdatawrite(sbi->direct_inode->i_mapping);
947-
}
953+
write_special_inodes(log, filemap_fdatawrite);
948954
else
949-
list_for_each_entry(sbi, &log->sb_list, log_list) {
950-
filemap_flush(sbi->ipbmap->i_mapping);
951-
filemap_flush(sbi->ipimap->i_mapping);
952-
filemap_flush(sbi->direct_inode->i_mapping);
953-
}
955+
write_special_inodes(log, filemap_flush);
954956

955957
/*
956958
* forward syncpt
@@ -1536,7 +1538,6 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
15361538
{
15371539
int i;
15381540
struct tblock *target = NULL;
1539-
struct jfs_sb_info *sbi;
15401541

15411542
/* jfs_write_inode may call us during read-only mount */
15421543
if (!log)
@@ -1598,11 +1599,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
15981599
if (wait < 2)
15991600
return;
16001601

1601-
list_for_each_entry(sbi, &log->sb_list, log_list) {
1602-
filemap_fdatawrite(sbi->ipbmap->i_mapping);
1603-
filemap_fdatawrite(sbi->ipimap->i_mapping);
1604-
filemap_fdatawrite(sbi->direct_inode->i_mapping);
1605-
}
1602+
write_special_inodes(log, filemap_fdatawrite);
16061603

16071604
/*
16081605
* If there was recent activity, we may need to wait
@@ -1611,6 +1608,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
16111608
if ((!list_empty(&log->cqueue)) || !list_empty(&log->synclist)) {
16121609
for (i = 0; i < 200; i++) { /* Too much? */
16131610
msleep(250);
1611+
write_special_inodes(log, filemap_fdatawrite);
16141612
if (list_empty(&log->cqueue) &&
16151613
list_empty(&log->synclist))
16161614
break;

fs/jfs/jfs_umount.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int jfs_umount(struct super_block *sb)
6868
/*
6969
* Wait for outstanding transactions to be written to log:
7070
*/
71-
jfs_flush_journal(log, 2);
71+
jfs_flush_journal(log, 1);
7272

7373
/*
7474
* close fileset inode allocation map (aka fileset inode)
@@ -146,7 +146,7 @@ int jfs_umount_rw(struct super_block *sb)
146146
*
147147
* remove file system from log active file system list.
148148
*/
149-
jfs_flush_journal(log, 2);
149+
jfs_flush_journal(log, 1);
150150

151151
/*
152152
* Make sure all metadata makes it to disk

0 commit comments

Comments
 (0)