From 06b534773d5a7dbfc9d0cf04fa6770a14c77d67d Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Sat, 4 May 2013 00:11:23 +0200 Subject: [PATCH] --- yaml --- r: 372728 b: refs/heads/master c: 5ae98f1589e076e4b314fc54ae2beac58842ddc2 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/linux/fs.h | 7 +++++++ trunk/kernel/acct.c | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index b25f95828ee7..3c9a5bf28a73 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9dcc26cf67fb7db7613290e62eeed6c4276c75ce +refs/heads/master: 5ae98f1589e076e4b314fc54ae2beac58842ddc2 diff --git a/trunk/include/linux/fs.h b/trunk/include/linux/fs.h index e8cd6b839675..b5a24ba83b6f 100644 --- a/trunk/include/linux/fs.h +++ b/trunk/include/linux/fs.h @@ -2227,6 +2227,13 @@ static inline void file_start_write(struct file *file) __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true); } +static inline bool file_start_write_trylock(struct file *file) +{ + if (!S_ISREG(file_inode(file)->i_mode)) + return true; + return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false); +} + static inline void file_end_write(struct file *file) { if (!S_ISREG(file_inode(file)->i_mode)) diff --git a/trunk/kernel/acct.c b/trunk/kernel/acct.c index 85389fe2abd0..8d6e145138bb 100644 --- a/trunk/kernel/acct.c +++ b/trunk/kernel/acct.c @@ -539,11 +539,16 @@ static void do_acct_process(struct bsd_acct_struct *acct, ac.ac_rw = encode_comp_t(ac.ac_io / 1024); ac.ac_swaps = encode_comp_t(0); + /* + * Get freeze protection. If the fs is frozen, just skip the write + * as we could deadlock the system otherwise. + */ + if (!file_start_write_trylock(file)) + goto out; /* * Kernel segment override to datasegment and write it * to the accounting file. */ - file_start_write(file); fs = get_fs(); set_fs(KERNEL_DS); /*