Commit 337e4a1ab4d736b8c39a4c3a233ac21f1a6c036f

Authored by Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/hirofumi/fatfs-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/hirofumi/fatfs-2.6:
  fat: make discard a mount option

Showing 3 changed files Side-by-side Diff

... ... @@ -44,7 +44,8 @@
44 44 nocase:1, /* Does this need case conversion? 0=need case conversion*/
45 45 usefree:1, /* Use free_clusters for FAT32 */
46 46 tz_utc:1, /* Filesystem timestamps are in UTC */
47   - rodir:1; /* allow ATTR_RO for directory */
  47 + rodir:1, /* allow ATTR_RO for directory */
  48 + discard:1; /* Issue discard requests on deletions */
48 49 };
49 50  
50 51 #define FAT_HASH_BITS 8
... ... @@ -566,16 +566,21 @@
566 566 goto error;
567 567 }
568 568  
569   - /*
570   - * Issue discard for the sectors we no longer care about,
571   - * batching contiguous clusters into one request
572   - */
573   - if (cluster != fatent.entry + 1) {
574   - int nr_clus = fatent.entry - first_cl + 1;
  569 + if (sbi->options.discard) {
  570 + /*
  571 + * Issue discard for the sectors we no longer
  572 + * care about, batching contiguous clusters
  573 + * into one request
  574 + */
  575 + if (cluster != fatent.entry + 1) {
  576 + int nr_clus = fatent.entry - first_cl + 1;
575 577  
576   - sb_issue_discard(sb, fat_clus_to_blknr(sbi, first_cl),
577   - nr_clus * sbi->sec_per_clus);
578   - first_cl = cluster;
  578 + sb_issue_discard(sb,
  579 + fat_clus_to_blknr(sbi, first_cl),
  580 + nr_clus * sbi->sec_per_clus);
  581 +
  582 + first_cl = cluster;
  583 + }
579 584 }
580 585  
581 586 ops->ent_put(&fatent, FAT_ENT_FREE);
... ... @@ -858,6 +858,8 @@
858 858 seq_puts(m, ",errors=panic");
859 859 else
860 860 seq_puts(m, ",errors=remount-ro");
  861 + if (opts->discard)
  862 + seq_puts(m, ",discard");
861 863  
862 864 return 0;
863 865 }
... ... @@ -871,7 +873,7 @@
871 873 Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes,
872 874 Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes,
873 875 Opt_obsolate, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont,
874   - Opt_err_panic, Opt_err_ro, Opt_err,
  876 + Opt_err_panic, Opt_err_ro, Opt_discard, Opt_err,
875 877 };
876 878  
877 879 static const match_table_t fat_tokens = {
... ... @@ -899,6 +901,7 @@
899 901 {Opt_err_cont, "errors=continue"},
900 902 {Opt_err_panic, "errors=panic"},
901 903 {Opt_err_ro, "errors=remount-ro"},
  904 + {Opt_discard, "discard"},
902 905 {Opt_obsolate, "conv=binary"},
903 906 {Opt_obsolate, "conv=text"},
904 907 {Opt_obsolate, "conv=auto"},
... ... @@ -1135,6 +1138,9 @@
1135 1138 break;
1136 1139 case Opt_rodir:
1137 1140 opts->rodir = 1;
  1141 + break;
  1142 + case Opt_discard:
  1143 + opts->discard = 1;
1138 1144 break;
1139 1145  
1140 1146 /* obsolete mount options */