All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Show a warning message if one of highest objectid reaches its max value
@ 2016-03-04  2:37 Satoru Takeuchi
  2016-03-04  9:28 ` Filipe Manana
  0 siblings, 1 reply; 3+ messages in thread
From: Satoru Takeuchi @ 2016-03-04  2:37 UTC (permalink / raw)
  To: linux-btrfs

- 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.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
This patch can be applied to v4.5-rc6
---
 fs/btrfs/inode-map.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index e50316c..a4860fd 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -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;
 	}

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Show a warning message if one of highest objectid reaches its max value
  2016-03-04  2:37 [PATCH] Show a warning message if one of highest objectid reaches its max value Satoru Takeuchi
@ 2016-03-04  9:28 ` Filipe Manana
  2016-03-06 23:08   ` Satoru Takeuchi
  0 siblings, 1 reply; 3+ messages in thread
From: Filipe Manana @ 2016-03-04  9:28 UTC (permalink / raw)
  To: Satoru Takeuchi; +Cc: linux-btrfs

On Fri, Mar 4, 2016 at 2:37 AM, Satoru Takeuchi
<takeuchi_satoru@jp.fujitsu.com> wrote:
> - 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.
>
> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
> ---
> This patch can be applied to v4.5-rc6
> ---
>  fs/btrfs/inode-map.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
> index e50316c..a4860fd 100644
> --- a/fs/btrfs/inode-map.c
> +++ b/fs/btrfs/inode-map.c
> @@ -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.

> +               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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
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."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Show a warning message if one of highest objectid reaches its max value
  2016-03-04  9:28 ` Filipe Manana
@ 2016-03-06 23:08   ` Satoru Takeuchi
  0 siblings, 0 replies; 3+ messages in thread
From: Satoru Takeuchi @ 2016-03-06 23:08 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

Hi Filipe,

On 2016/03/04 18:28, Filipe Manana wrote:
> On Fri, Mar 4, 2016 at 2:37 AM, Satoru Takeuchi
> <takeuchi_satoru@jp.fujitsu.com> wrote:
>> - 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.
>>
>> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
>> ---
>> This patch can be applied to v4.5-rc6
>> ---
>>   fs/btrfs/inode-map.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
>> index e50316c..a4860fd 100644
>> --- a/fs/btrfs/inode-map.c
>> +++ b/fs/btrfs/inode-map.c
>> @@ -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.

Thank you for your comment. I'll fix it.
>
>> +               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 majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-06 23:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-04  2:37 [PATCH] Show a warning message if one of highest objectid reaches its max value Satoru Takeuchi
2016-03-04  9:28 ` Filipe Manana
2016-03-06 23:08   ` Satoru Takeuchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.