fs: Fix hang with BSD accounting on frozen filesystem
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / kernel / acct.c
index 85389fe2abd0a95bf99d4abe6b1de63e09351c4c..8d6e145138bb9d2e39e93933177f63536d73d018 100644 (file)
@@ -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);
        /*