UBIFS: allow for sync_fs when read-only
authorAdrian Hunter <ext-adrian.hunter@nokia.com>
Thu, 11 Sep 2008 11:25:44 +0000 (14:25 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 30 Sep 2008 08:12:58 +0000 (11:12 +0300)
sync_fs can be called even if the file system is mounted
read-only.  Ensure the commit is not run in that case.

Reported-by: Zoltan Sogor <weth@inf.u-szeged.hu>
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
fs/ubifs/super.c

index 7e1f3efdf632d691711c2425e7009ecbb83d3ea8..7fd759dde7968b6560426d76139537420317305e 100644 (file)
@@ -420,21 +420,22 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
        int i, ret = 0, err;
        long long bud_bytes;
 
-       if (c->jheads)
+       if (c->jheads) {
                for (i = 0; i < c->jhead_cnt; i++) {
                        err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
                        if (err && !ret)
                                ret = err;
                }
 
-       /* Commit the journal unless it has too few data */
-       spin_lock(&c->buds_lock);
-       bud_bytes = c->bud_bytes;
-       spin_unlock(&c->buds_lock);
-       if (bud_bytes > c->leb_size) {
-               err = ubifs_run_commit(c);
-               if (err)
-                       return err;
+               /* Commit the journal unless it has too little data */
+               spin_lock(&c->buds_lock);
+               bud_bytes = c->bud_bytes;
+               spin_unlock(&c->buds_lock);
+               if (bud_bytes > c->leb_size) {
+                       err = ubifs_run_commit(c);
+                       if (err)
+                               return err;
+               }
        }
 
        /*