Skip to contentSkip to conversation

Show a warning message if one of highest objectid reaches its max value

PATCH Superseded Satoru Takeuchi 2 participants 3 messages Mar 4, 2016 – Mar 6, 2016 Btrfs file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Show a warning message if one of highest objectid reaches its max value

- It's better to show a warning message for the exceptional case that one of highest objectid (in most case, inode number) reaches its max value, BTRFS_LAST_FREE_OBJECTID. Show this message only once to avoid filling dmesg with it.
- EOVERFLOW is more proper return value for this case. ENOSPC is for "No space left on device" case and objectid isn't related to any device.

---
This patch can be applied to v4.5-rc6

---
 fs/btrfs/inode-map.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/inode-map.c +4 -2
index e50316c..a4860fd 100644
@@ -555,8 +555,10 @@ int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid)
 	int ret;
 	mutex_lock(&root->objectid_mutex);
 
-	if (unlikely(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID)) {
-		ret = -ENOSPC;
+	if (WARN_ONCE(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID,
+		      "BTRFS: The highest objectid reaches its max value %llu.\n",
+		      BTRFS_LAST_FREE_OBJECTID)) {
+		ret = -EOVERFLOW;
 		goto out;
 	}
 
Signature · 5 lines
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-
#1 lore raw
Quoted 20 lines · Satoru Takeuchi

- It's better to show a warning message for the exceptional case that one of highest objectid (in most case, inode number) reaches its max value, BTRFS_LAST_FREE_OBJECTID. Show this message only once to avoid filling dmesg with it.
- EOVERFLOW is more proper return value for this case. ENOSPC is for "No space left on device" case and objectid isn't related to any device.

---
This patch can be applied to v4.5-rc6

---
 fs/btrfs/inode-map.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/inode-map.c +0 -0
index e50316c..a4860fd 100644

fs/btrfs/inode-map.c int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid) · line 560

Quoted 8 lines
fs/btrfs/inode-map.c +3 -2
@@ -555,8 +555,10 @@ int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid)
        int ret;
        mutex_lock(&root->objectid_mutex);
 
-       if (unlikely(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID)) {
-               ret = -ENOSPC;
+       if (WARN_ONCE(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID,
+                     "BTRFS: The highest objectid reaches its max value %llu.\n",
+                     BTRFS_LAST_FREE_OBJECTID)) {

Please, use btrfs_warn() to print messages... It avoids hardcoding prefixes and having to copy the style of the btrfs_[info|warn|error|...) functions.
Also include the id of the tree (root->root_key.objectid), it's much more useful than printing root->highes_objectid....

Also add the prefix "Btrfs: " to the subject.

Quoted 10 lines
fs/btrfs/inode-map.c +1 -1
+               ret = -EOVERFLOW;
                goto out;
        }
 
--

2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 5 lines
Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."
#2 lore raw

Hi Filipe,

Quoted 37 lines · Filipe Manana
Quoted 20 lines · Satoru Takeuchi

- It's better to show a warning message for the exceptional case that one of highest objectid (in most case, inode number) reaches its max value, BTRFS_LAST_FREE_OBJECTID. Show this message only once to avoid filling dmesg with it.
- EOVERFLOW is more proper return value for this case. ENOSPC is for "No space left on device" case and objectid isn't related to any device.

---
This patch can be applied to v4.5-rc6

---
  fs/btrfs/inode-map.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/inode-map.c +0 -0
index e50316c..a4860fd 100644

fs/btrfs/inode-map.c int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid) · line 560

Quoted 8 lines
fs/btrfs/inode-map.c +3 -2
@@ -555,8 +555,10 @@ int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid)
         int ret;
         mutex_lock(&root->objectid_mutex);
 
-       if (unlikely(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID)) {
-               ret = -ENOSPC;
+       if (WARN_ONCE(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID,
+                     "BTRFS: The highest objectid reaches its max value %llu.\n",
+                     BTRFS_LAST_FREE_OBJECTID)) {

Please, use btrfs_warn() to print messages... It avoids hardcoding prefixes and having to copy the style of the btrfs_[info|warn|error|...) functions.
Also include the id of the tree (root->root_key.objectid), it's much more useful than printing root->highes_objectid....

Quoted 1 line

Also add the prefix "Btrfs: " to the subject.

Thank you for your comment. I'll fix it.

Quoted 14 lines
Quoted 11 lines
fs/btrfs/inode-map.c +1 -1
+               ret = -EOVERFLOW;
                 goto out;
         }
 
--

2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html