* [PATCH] btrfs: Simplify len alignment calculation
@ 2019-11-29 9:38 Nikolay Borisov
2019-12-03 7:52 ` Omar Sandoval
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2019-11-29 9:38 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
Use ALIGN() directly rather than achieving the same thing in a roundabout way.
No semantic changes.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/delalloc-space.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
index 4cdac4d834f5..c08e905b0424 100644
--- a/fs/btrfs/delalloc-space.c
+++ b/fs/btrfs/delalloc-space.c
@@ -142,8 +142,7 @@ int btrfs_check_data_free_space(struct inode *inode,
int ret;
/* align the range */
- len = round_up(start + len, fs_info->sectorsize) -
- round_down(start, fs_info->sectorsize);
+ len = ALIGN(len, fs_info->sectorsize);
start = round_down(start, fs_info->sectorsize);
ret = btrfs_alloc_data_chunk_ondemand(BTRFS_I(inode), len);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Simplify len alignment calculation
2019-11-29 9:38 [PATCH] btrfs: Simplify len alignment calculation Nikolay Borisov
@ 2019-12-03 7:52 ` Omar Sandoval
2019-12-03 8:06 ` Nikolay Borisov
0 siblings, 1 reply; 3+ messages in thread
From: Omar Sandoval @ 2019-12-03 7:52 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Fri, Nov 29, 2019 at 11:38:07AM +0200, Nikolay Borisov wrote:
> Use ALIGN() directly rather than achieving the same thing in a roundabout way.
> No semantic changes.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/delalloc-space.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
> index 4cdac4d834f5..c08e905b0424 100644
> --- a/fs/btrfs/delalloc-space.c
> +++ b/fs/btrfs/delalloc-space.c
> @@ -142,8 +142,7 @@ int btrfs_check_data_free_space(struct inode *inode,
> int ret;
>
> /* align the range */
> - len = round_up(start + len, fs_info->sectorsize) -
> - round_down(start, fs_info->sectorsize);
> + len = ALIGN(len, fs_info->sectorsize);
Consider sectorsize = 4096, start = 4095, len = 2. This range spans two
blocks, which is what the original compuation gives. Yours returns one
block instead.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Simplify len alignment calculation
2019-12-03 7:52 ` Omar Sandoval
@ 2019-12-03 8:06 ` Nikolay Borisov
0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2019-12-03 8:06 UTC (permalink / raw)
To: Omar Sandoval; +Cc: linux-btrfs
On 3.12.19 г. 9:52 ч., Omar Sandoval wrote:
> On Fri, Nov 29, 2019 at 11:38:07AM +0200, Nikolay Borisov wrote:
>> Use ALIGN() directly rather than achieving the same thing in a roundabout way.
>> No semantic changes.
>>
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>> ---
>> fs/btrfs/delalloc-space.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
>> index 4cdac4d834f5..c08e905b0424 100644
>> --- a/fs/btrfs/delalloc-space.c
>> +++ b/fs/btrfs/delalloc-space.c
>> @@ -142,8 +142,7 @@ int btrfs_check_data_free_space(struct inode *inode,
>> int ret;
>>
>> /* align the range */
>> - len = round_up(start + len, fs_info->sectorsize) -
>> - round_down(start, fs_info->sectorsize);
>> + len = ALIGN(len, fs_info->sectorsize);
>
> Consider sectorsize = 4096, start = 4095, len = 2. This range spans two
> blocks, which is what the original compuation gives. Yours returns one
> block instead.
>
Doh, you are right. I copied this approach from your [RFC PATCH v3
09/12] btrfs: support different disk extent size for delalloc patch.
Doesn't it suffer from the same bug?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-03 8:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 9:38 [PATCH] btrfs: Simplify len alignment calculation Nikolay Borisov
2019-12-03 7:52 ` Omar Sandoval
2019-12-03 8:06 ` Nikolay Borisov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).