* [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls
@ 2017-10-10 10:48 Rakesh Pandit
2017-10-10 11:00 ` Nikolay Borisov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Rakesh Pandit @ 2017-10-10 10:48 UTC (permalink / raw)
To: linux-btrfs, linux-kernel; +Cc: David Sterba, Josef Bacik, Chris Mason
Commit a53f4f8e9c8eb ("btrfs: Don't call btrfs_start_transaction() on
frozen fs to avoid deadlock.") started using internal calls and we
replace them with more suitable ones.
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
---
fs/btrfs/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 35a128a..99c21ae 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1205,8 +1205,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
* happens. The pending operations are delayed to the
* next commit after thawing.
*/
- if (__sb_start_write(sb, SB_FREEZE_WRITE, false))
- __sb_end_write(sb, SB_FREEZE_WRITE);
+ if (sb_start_write_trylock(sb))
+ sb_end_write(sb)
else
return 0;
trans = btrfs_start_transaction(root, 0);
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls
2017-10-10 10:48 [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls Rakesh Pandit
@ 2017-10-10 11:00 ` Nikolay Borisov
2017-10-10 11:04 ` Rakesh Pandit
2017-10-10 11:08 ` Nikolay Borisov
2017-10-10 13:20 ` David Sterba
2 siblings, 1 reply; 6+ messages in thread
From: Nikolay Borisov @ 2017-10-10 11:00 UTC (permalink / raw)
To: Rakesh Pandit, linux-btrfs, linux-kernel
Cc: David Sterba, Josef Bacik, Chris Mason
On 10.10.2017 13:48, Rakesh Pandit wrote:
> Commit a53f4f8e9c8eb ("btrfs: Don't call btrfs_start_transaction() on
> frozen fs to avoid deadlock.") started using internal calls and we
> replace them with more suitable ones.
>
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> fs/btrfs/super.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 35a128a..99c21ae 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1205,8 +1205,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
> * happens. The pending operations are delayed to the
> * next commit after thawing.
> */
> - if (__sb_start_write(sb, SB_FREEZE_WRITE, false))
> - __sb_end_write(sb, SB_FREEZE_WRITE);
> + if (sb_start_write_trylock(sb))
> + sb_end_write(sb)
> else
> return 0;
> trans = btrfs_start_transaction(root, 0);
The non __ versions are just wrappers around the __ specific calls. So
the code is identical.
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls
2017-10-10 11:00 ` Nikolay Borisov
@ 2017-10-10 11:04 ` Rakesh Pandit
0 siblings, 0 replies; 6+ messages in thread
From: Rakesh Pandit @ 2017-10-10 11:04 UTC (permalink / raw)
To: Nikolay Borisov
Cc: linux-btrfs, linux-kernel, David Sterba, Josef Bacik, Chris Mason
On Tue, Oct 10, 2017 at 02:00:20PM +0300, Nikolay Borisov wrote:
>
>
> On 10.10.2017 13:48, Rakesh Pandit wrote:
> > Commit a53f4f8e9c8eb ("btrfs: Don't call btrfs_start_transaction() on
> > frozen fs to avoid deadlock.") started using internal calls and we
> > replace them with more suitable ones.
> >
> > Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> > ---
> > fs/btrfs/super.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> > index 35a128a..99c21ae 100644
> > --- a/fs/btrfs/super.c
> > +++ b/fs/btrfs/super.c
> > @@ -1205,8 +1205,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
> > * happens. The pending operations are delayed to the
> > * next commit after thawing.
> > */
> > - if (__sb_start_write(sb, SB_FREEZE_WRITE, false))
> > - __sb_end_write(sb, SB_FREEZE_WRITE);
> > + if (sb_start_write_trylock(sb))
> > + sb_end_write(sb)
> > else
> > return 0;
> > trans = btrfs_start_transaction(root, 0);
>
> The non __ versions are just wrappers around the __ specific calls. So
> the code is identical.
>
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>
Thanks, yes indeed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls
2017-10-10 10:48 [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls Rakesh Pandit
2017-10-10 11:00 ` Nikolay Borisov
@ 2017-10-10 11:08 ` Nikolay Borisov
2017-10-10 13:13 ` Rakesh Pandit
2017-10-10 13:20 ` David Sterba
2 siblings, 1 reply; 6+ messages in thread
From: Nikolay Borisov @ 2017-10-10 11:08 UTC (permalink / raw)
To: Rakesh Pandit, linux-btrfs, linux-kernel
Cc: David Sterba, Josef Bacik, Chris Mason
On 10.10.2017 13:48, Rakesh Pandit wrote:
> Commit a53f4f8e9c8eb ("btrfs: Don't call btrfs_start_transaction() on
> frozen fs to avoid deadlock.") started using internal calls and we
> replace them with more suitable ones.
>
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> fs/btrfs/super.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 35a128a..99c21ae 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1205,8 +1205,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
> * happens. The pending operations are delayed to the
> * next commit after thawing.
> */
> - if (__sb_start_write(sb, SB_FREEZE_WRITE, false))
> - __sb_end_write(sb, SB_FREEZE_WRITE);
> + if (sb_start_write_trylock(sb))
> + sb_end_write(sb)
> else
> return 0;
On second thought, what's to prevent the filesystem to be frozen if
sb_start_write/sb_end_write code executes? Or even after we are in the
middle of btrfs_start_transaction?
> trans = btrfs_start_transaction(root, 0);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls
2017-10-10 11:08 ` Nikolay Borisov
@ 2017-10-10 13:13 ` Rakesh Pandit
0 siblings, 0 replies; 6+ messages in thread
From: Rakesh Pandit @ 2017-10-10 13:13 UTC (permalink / raw)
To: Nikolay Borisov
Cc: linux-btrfs, linux-kernel, David Sterba, Josef Bacik, Chris Mason
On Tue, Oct 10, 2017 at 02:08:11PM +0300, Nikolay Borisov wrote:
>
>
> On 10.10.2017 13:48, Rakesh Pandit wrote:
> > Commit a53f4f8e9c8eb ("btrfs: Don't call btrfs_start_transaction() on
> > frozen fs to avoid deadlock.") started using internal calls and we
> > replace them with more suitable ones.
> >
> > Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> > ---
> > fs/btrfs/super.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> > index 35a128a..99c21ae 100644
> > --- a/fs/btrfs/super.c
> > +++ b/fs/btrfs/super.c
> > @@ -1205,8 +1205,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
> > * happens. The pending operations are delayed to the
> > * next commit after thawing.
> > */
> > - if (__sb_start_write(sb, SB_FREEZE_WRITE, false))
> > - __sb_end_write(sb, SB_FREEZE_WRITE);
> > + if (sb_start_write_trylock(sb))
> > + sb_end_write(sb)
> > else
> > return 0;
>
> On second thought, what's to prevent the filesystem to be frozen if
> sb_start_write/sb_end_write code executes? Or even after we are in the
> middle of btrfs_start_transaction?
sb->s_writers.frozen is protected by sb->s_umount and s_umount is
held when ->sync_fs is called.
>
>
> > trans = btrfs_start_transaction(root, 0);
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls
2017-10-10 10:48 [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls Rakesh Pandit
2017-10-10 11:00 ` Nikolay Borisov
2017-10-10 11:08 ` Nikolay Borisov
@ 2017-10-10 13:20 ` David Sterba
2 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2017-10-10 13:20 UTC (permalink / raw)
To: Rakesh Pandit
Cc: linux-btrfs, linux-kernel, David Sterba, Josef Bacik, Chris Mason
On Tue, Oct 10, 2017 at 01:48:05PM +0300, Rakesh Pandit wrote:
> Commit a53f4f8e9c8eb ("btrfs: Don't call btrfs_start_transaction() on
> frozen fs to avoid deadlock.") started using internal calls and we
> replace them with more suitable ones.
>
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> fs/btrfs/super.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 35a128a..99c21ae 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1205,8 +1205,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
> * happens. The pending operations are delayed to the
> * next commit after thawing.
> */
> - if (__sb_start_write(sb, SB_FREEZE_WRITE, false))
> - __sb_end_write(sb, SB_FREEZE_WRITE);
> + if (sb_start_write_trylock(sb))
> + sb_end_write(sb)
CC [M] fs/btrfs/print-tree.o
fs/btrfs/super.c: In function ‘btrfs_sync_fs’:
fs/btrfs/super.c:1210:4: error: expected ‘;’ before ‘else’
else
^~~~
will be fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-10 13:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-10 10:48 [PATCH] btrfs: use appropriate replacements for __sb_{start,end}_write calls Rakesh Pandit
2017-10-10 11:00 ` Nikolay Borisov
2017-10-10 11:04 ` Rakesh Pandit
2017-10-10 11:08 ` Nikolay Borisov
2017-10-10 13:13 ` Rakesh Pandit
2017-10-10 13:20 ` David Sterba
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).