btrfs: more graceful errors/warnings on 32bit systems when reaching limits
[sfrench/cifs-2.6.git] / fs / btrfs / super.c
index f7a4ad86adee61610c686f7321d23f5676a983e3..4a396c1147f177c159909390806a153f22fe9f55 100644 (file)
@@ -252,6 +252,32 @@ void __cold btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, .
 }
 #endif
 
+#if BITS_PER_LONG == 32
+void __cold btrfs_warn_32bit_limit(struct btrfs_fs_info *fs_info)
+{
+       if (!test_and_set_bit(BTRFS_FS_32BIT_WARN, &fs_info->flags)) {
+               btrfs_warn(fs_info, "reaching 32bit limit for logical addresses");
+               btrfs_warn(fs_info,
+"due to page cache limit on 32bit systems, btrfs can't access metadata at or beyond %lluT",
+                          BTRFS_32BIT_MAX_FILE_SIZE >> 40);
+               btrfs_warn(fs_info,
+                          "please consider upgrading to 64bit kernel/hardware");
+       }
+}
+
+void __cold btrfs_err_32bit_limit(struct btrfs_fs_info *fs_info)
+{
+       if (!test_and_set_bit(BTRFS_FS_32BIT_ERROR, &fs_info->flags)) {
+               btrfs_err(fs_info, "reached 32bit limit for logical addresses");
+               btrfs_err(fs_info,
+"due to page cache limit on 32bit systems, metadata beyond %lluT can't be accessed",
+                         BTRFS_32BIT_MAX_FILE_SIZE >> 40);
+               btrfs_err(fs_info,
+                          "please consider upgrading to 64bit kernel/hardware");
+       }
+}
+#endif
+
 /*
  * We only mark the transaction aborted and then set the file system read-only.
  * This will prevent new transactions from starting or trying to join this