fat: do not send discards as barriers
[linux-2.6.git] / fs / fat / fatent.c
index 618f530..f9a0b7a 100644 (file)
@@ -348,7 +348,7 @@ int fat_ent_read(struct inode *inode, struct fat_entry *fatent, int entry)
 
        if (entry < FAT_START_ENT || sbi->max_cluster <= entry) {
                fatent_brelse(fatent);
-               fat_fs_panic(sb, "invalid access to FAT (entry 0x%08x)", entry);
+               fat_fs_error(sb, "invalid access to FAT (entry 0x%08x)", entry);
                return -EIO;
        }
 
@@ -560,22 +560,29 @@ int fat_free_clusters(struct inode *inode, int cluster)
                        err = cluster;
                        goto error;
                } else if (cluster == FAT_ENT_FREE) {
-                       fat_fs_panic(sb, "%s: deleting FAT entry beyond EOF",
+                       fat_fs_error(sb, "%s: deleting FAT entry beyond EOF",
                                     __func__);
                        err = -EIO;
                        goto error;
                }
 
-               /* 
-                * Issue discard for the sectors we no longer care about,
-                * batching contiguous clusters into one request
-                */
-               if (cluster != fatent.entry + 1) {
-                       int nr_clus = fatent.entry - first_cl + 1;
-
-                       sb_issue_discard(sb, fat_clus_to_blknr(sbi, first_cl),
-                                        nr_clus * sbi->sec_per_clus);
-                       first_cl = cluster;
+               if (sbi->options.discard) {
+                       /*
+                        * Issue discard for the sectors we no longer
+                        * care about, batching contiguous clusters
+                        * into one request
+                        */
+                       if (cluster != fatent.entry + 1) {
+                               int nr_clus = fatent.entry - first_cl + 1;
+
+                               sb_issue_discard(sb,
+                                       fat_clus_to_blknr(sbi, first_cl),
+                                       nr_clus * sbi->sec_per_clus,
+                                       GFP_NOFS,
+                                       BLKDEV_IFL_WAIT);
+
+                               first_cl = cluster;
+                       }
                }
 
                ops->ent_put(&fatent, FAT_ENT_FREE);