* Re: [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write
2018-12-11 8:23 [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write Nikolay Borisov
@ 2019-01-03 12:06 ` Nikolay Borisov
2019-01-24 11:01 ` Nikolay Borisov
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2019-01-03 12:06 UTC (permalink / raw)
To: tytso; +Cc: adilger.kernel, linux-ext4
On 11.12.18 г. 10:23 ч., Nikolay Borisov wrote:
> There is a function which clearly conveys the objective of checking
> i_writecount. Additionally the usage in ext4_mb_initialize_context was
> wrong, since a node would have wrongfully been reported as writable if
> i_writecount had a negative value (MMAP_DENY_WRITE).
>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Gentle ping
> ---
> fs/ext4/inode.c | 2 +-
> fs/ext4/mballoc.c | 7 +++----
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 22a9d8159720..04e5bc0b5c8d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
> * inode's preallocations.
> */
> if ((ei->i_reserved_data_blocks == 0) &&
> - (atomic_read(&inode->i_writecount) == 0))
> + !inode_is_open_for_write(inode))
> ext4_discard_preallocations(inode);
> }
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index e2248083cdca..6fb76d408093 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
> isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1)
> >> bsbits;
>
> - if ((size == isize) &&
> - !ext4_fs_is_busy(sbi) &&
> - (atomic_read(&ac->ac_inode->i_writecount) == 0)) {
> + if ((size == isize) && !ext4_fs_is_busy(sbi) &&
> + !inode_is_open_for_write(ac->ac_inode)) {
> ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
> return;
> }
> @@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
> (unsigned) ar->goal, ac->ac_flags, ac->ac_2order,
> (unsigned) ar->lleft, (unsigned) ar->pleft,
> (unsigned) ar->lright, (unsigned) ar->pright,
> - atomic_read(&ar->inode->i_writecount) ? "" : "non-");
> + inode_is_open_for_write(ar->inode) ? "" : "non-");
> return 0;
>
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write
2018-12-11 8:23 [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write Nikolay Borisov
2019-01-03 12:06 ` Nikolay Borisov
@ 2019-01-24 11:01 ` Nikolay Borisov
2019-01-30 1:23 ` Andreas Dilger
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2019-01-24 11:01 UTC (permalink / raw)
To: tytso; +Cc: adilger.kernel, linux-ext4, jack
On 11.12.18 г. 10:23 ч., Nikolay Borisov wrote:
> There is a function which clearly conveys the objective of checking
> i_writecount. Additionally the usage in ext4_mb_initialize_context was
> wrong, since a node would have wrongfully been reported as writable if
> i_writecount had a negative value (MMAP_DENY_WRITE).
>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Yet another ping, if something is wrong with the patch I'm happy to fix
it and get it merged.
> ---
> fs/ext4/inode.c | 2 +-
> fs/ext4/mballoc.c | 7 +++----
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 22a9d8159720..04e5bc0b5c8d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
> * inode's preallocations.
> */
> if ((ei->i_reserved_data_blocks == 0) &&
> - (atomic_read(&inode->i_writecount) == 0))
> + !inode_is_open_for_write(inode))
> ext4_discard_preallocations(inode);
> }
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index e2248083cdca..6fb76d408093 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
> isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1)
> >> bsbits;
>
> - if ((size == isize) &&
> - !ext4_fs_is_busy(sbi) &&
> - (atomic_read(&ac->ac_inode->i_writecount) == 0)) {
> + if ((size == isize) && !ext4_fs_is_busy(sbi) &&
> + !inode_is_open_for_write(ac->ac_inode)) {
> ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
> return;
> }
> @@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
> (unsigned) ar->goal, ac->ac_flags, ac->ac_2order,
> (unsigned) ar->lleft, (unsigned) ar->pleft,
> (unsigned) ar->lright, (unsigned) ar->pright,
> - atomic_read(&ar->inode->i_writecount) ? "" : "non-");
> + inode_is_open_for_write(ar->inode) ? "" : "non-");
> return 0;
>
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write
2018-12-11 8:23 [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write Nikolay Borisov
2019-01-03 12:06 ` Nikolay Borisov
2019-01-24 11:01 ` Nikolay Borisov
@ 2019-01-30 1:23 ` Andreas Dilger
2019-02-10 10:47 ` Nikolay Borisov
2019-02-11 4:07 ` Theodore Y. Ts'o
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Dilger @ 2019-01-30 1:23 UTC (permalink / raw)
To: Theodore Y. Ts'o; +Cc: Nikolay Borisov, Ext4 Developers List
[-- Attachment #1: Type: text/plain, Size: 2140 bytes --]
On Dec 11, 2018, at 1:23 AM, Nikolay Borisov <nborisov@suse.com> wrote:
>
> There is a function which clearly conveys the objective of checking
> i_writecount. Additionally the usage in ext4_mb_initialize_context was
> wrong, since a node would have wrongfully been reported as writable if
> i_writecount had a negative value (MMAP_DENY_WRITE).
>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
> ---
> fs/ext4/inode.c | 2 +-
> fs/ext4/mballoc.c | 7 +++----
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 22a9d8159720..04e5bc0b5c8d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
> * inode's preallocations.
> */
> if ((ei->i_reserved_data_blocks == 0) &&
> - (atomic_read(&inode->i_writecount) == 0))
> + !inode_is_open_for_write(inode))
> ext4_discard_preallocations(inode);
> }
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index e2248083cdca..6fb76d408093 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
> isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1)
> >> bsbits;
>
> - if ((size == isize) &&
> - !ext4_fs_is_busy(sbi) &&
> - (atomic_read(&ac->ac_inode->i_writecount) == 0)) {
> + if ((size == isize) && !ext4_fs_is_busy(sbi) &&
> + !inode_is_open_for_write(ac->ac_inode)) {
> ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
> return;
> }
> @@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
> (unsigned) ar->goal, ac->ac_flags, ac->ac_2order,
> (unsigned) ar->lleft, (unsigned) ar->pleft,
> (unsigned) ar->lright, (unsigned) ar->pright,
> - atomic_read(&ar->inode->i_writecount) ? "" : "non-");
> + inode_is_open_for_write(ar->inode) ? "" : "non-");
> return 0;
>
> }
> --
> 2.17.1
>
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write
2018-12-11 8:23 [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write Nikolay Borisov
` (2 preceding siblings ...)
2019-01-30 1:23 ` Andreas Dilger
@ 2019-02-10 10:47 ` Nikolay Borisov
2019-02-11 4:07 ` Theodore Y. Ts'o
4 siblings, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2019-02-10 10:47 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4
On 11.12.18 г. 10:23 ч., Nikolay Borisov wrote:
> There is a function which clearly conveys the objective of checking
> i_writecount. Additionally the usage in ext4_mb_initialize_context was
> wrong, since a node would have wrongfully been reported as writable if
> i_writecount had a negative value (MMAP_DENY_WRITE).
>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Yet another ping ?
> ---
> fs/ext4/inode.c | 2 +-
> fs/ext4/mballoc.c | 7 +++----
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 22a9d8159720..04e5bc0b5c8d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
> * inode's preallocations.
> */
> if ((ei->i_reserved_data_blocks == 0) &&
> - (atomic_read(&inode->i_writecount) == 0))
> + !inode_is_open_for_write(inode))
> ext4_discard_preallocations(inode);
> }
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index e2248083cdca..6fb76d408093 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
> isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1)
> >> bsbits;
>
> - if ((size == isize) &&
> - !ext4_fs_is_busy(sbi) &&
> - (atomic_read(&ac->ac_inode->i_writecount) == 0)) {
> + if ((size == isize) && !ext4_fs_is_busy(sbi) &&
> + !inode_is_open_for_write(ac->ac_inode)) {
> ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
> return;
> }
> @@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
> (unsigned) ar->goal, ac->ac_flags, ac->ac_2order,
> (unsigned) ar->lleft, (unsigned) ar->pleft,
> (unsigned) ar->lright, (unsigned) ar->pright,
> - atomic_read(&ar->inode->i_writecount) ? "" : "non-");
> + inode_is_open_for_write(ar->inode) ? "" : "non-");
> return 0;
>
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write
2018-12-11 8:23 [PATCH] ext4: Replace opencoded i_writecount usage with inode_is_open_for_write Nikolay Borisov
` (3 preceding siblings ...)
2019-02-10 10:47 ` Nikolay Borisov
@ 2019-02-11 4:07 ` Theodore Y. Ts'o
4 siblings, 0 replies; 6+ messages in thread
From: Theodore Y. Ts'o @ 2019-02-11 4:07 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: adilger.kernel, linux-ext4
On Tue, Dec 11, 2018 at 10:23:55AM +0200, Nikolay Borisov wrote:
> There is a function which clearly conveys the objective of checking
> i_writecount. Additionally the usage in ext4_mb_initialize_context was
> wrong, since a node would have wrongfully been reported as writable if
> i_writecount had a negative value (MMAP_DENY_WRITE).
>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 6+ messages in thread