diff mbox

[07/11] xfs: remove not needed freezing calls

Message ID 20171129232356.28296-8-mcgrof@kernel.org (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Luis Chamberlain Nov. 29, 2017, 11:23 p.m. UTC
This removes superflous freezer calls as they are no longer needed
as the VFS now performs filesystem freezing/thaw if the filesystem has
support for it.

The following Coccinelle rule was used as follows:

spatch --sp-file fs-freeze-cleanup.cocci --in-place fs/$FS/

@ has_freeze_fs @
identifier super_ops;
expression freeze_op;
@@

struct super_operations super_ops = {
	.freeze_fs = freeze_op,
};

@ remove_set_freezable depends on has_freeze_fs @
expression time;
statement S, S2, S3;
expression task;
@@

(
-	set_freezable();
|
-	if (try_to_freeze())
-		continue;
|
-	try_to_freeze();
|
-	freezable_schedule();
+	schedule();
|
-	freezable_schedule_timeout(time);
+	schedule_timeout(time);
|
-	if (freezing(task)) { S }
|
-	if (freezing(task)) { S }
-	else
	{ S2 }
|
-	freezing(current)
)

Generated-by: Coccinelle SmPL
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 fs/xfs/xfs_trans_ail.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Jan Kara Nov. 30, 2017, 4:21 p.m. UTC | #1
On Wed 29-11-17 15:23:52, Luis R. Rodriguez wrote:
> This removes superflous freezer calls as they are no longer needed
> as the VFS now performs filesystem freezing/thaw if the filesystem has
> support for it.
> 
> The following Coccinelle rule was used as follows:
> 
> spatch --sp-file fs-freeze-cleanup.cocci --in-place fs/$FS/

I think your rule misses WQ_FREEZABLE flag for workqueues? That would be
also good to get rid of...

								Honza

> 
> @ has_freeze_fs @
> identifier super_ops;
> expression freeze_op;
> @@
> 
> struct super_operations super_ops = {
> 	.freeze_fs = freeze_op,
> };
> 
> @ remove_set_freezable depends on has_freeze_fs @
> expression time;
> statement S, S2, S3;
> expression task;
> @@
> 
> (
> -	set_freezable();
> |
> -	if (try_to_freeze())
> -		continue;
> |
> -	try_to_freeze();
> |
> -	freezable_schedule();
> +	schedule();
> |
> -	freezable_schedule_timeout(time);
> +	schedule_timeout(time);
> |
> -	if (freezing(task)) { S }
> |
> -	if (freezing(task)) { S }
> -	else
> 	{ S2 }
> |
> -	freezing(current)
> )
> 
> Generated-by: Coccinelle SmPL
> Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
> ---
>  fs/xfs/xfs_trans_ail.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> index cef89f7127d3..1f3dd10a9d00 100644
> --- a/fs/xfs/xfs_trans_ail.c
> +++ b/fs/xfs/xfs_trans_ail.c
> @@ -513,7 +513,6 @@ xfsaild(
>  	long		tout = 0;	/* milliseconds */
>  
>  	current->flags |= PF_MEMALLOC;
> -	set_freezable();
>  
>  	while (1) {
>  		if (tout && tout <= 20)
> @@ -551,19 +550,17 @@ xfsaild(
>  		if (!xfs_ail_min(ailp) &&
>  		    ailp->xa_target == ailp->xa_target_prev) {
>  			spin_unlock(&ailp->xa_lock);
> -			freezable_schedule();
> +			schedule();
>  			tout = 0;
>  			continue;
>  		}
>  		spin_unlock(&ailp->xa_lock);
>  
>  		if (tout)
> -			freezable_schedule_timeout(msecs_to_jiffies(tout));
> +			schedule_timeout(msecs_to_jiffies(tout));
>  
>  		__set_current_state(TASK_RUNNING);
>  
> -		try_to_freeze();
> -
>  		tout = xfsaild_push(ailp);
>  	}
>  
> -- 
> 2.15.0
>
Rafael J. Wysocki Nov. 30, 2017, 8:32 p.m. UTC | #2
On Thu, Nov 30, 2017 at 5:21 PM, Jan Kara <jack@suse.cz> wrote:
> On Wed 29-11-17 15:23:52, Luis R. Rodriguez wrote:
>> This removes superflous freezer calls as they are no longer needed
>> as the VFS now performs filesystem freezing/thaw if the filesystem has
>> support for it.
>>
>> The following Coccinelle rule was used as follows:
>>
>> spatch --sp-file fs-freeze-cleanup.cocci --in-place fs/$FS/
>
> I think your rule misses WQ_FREEZABLE flag for workqueues? That would be
> also good to get rid of...

We need that one (or equivalent) for the runtime PM workqueue at least.

Thanks,
Rafael
Dave Chinner Nov. 30, 2017, 11:30 p.m. UTC | #3
On Thu, Nov 30, 2017 at 09:32:53PM +0100, Rafael J. Wysocki wrote:
> On Thu, Nov 30, 2017 at 5:21 PM, Jan Kara <jack@suse.cz> wrote:
> > On Wed 29-11-17 15:23:52, Luis R. Rodriguez wrote:
> >> This removes superflous freezer calls as they are no longer needed
> >> as the VFS now performs filesystem freezing/thaw if the filesystem has
> >> support for it.
> >>
> >> The following Coccinelle rule was used as follows:
> >>
> >> spatch --sp-file fs-freeze-cleanup.cocci --in-place fs/$FS/
> >
> > I think your rule misses WQ_FREEZABLE flag for workqueues? That would be
> > also good to get rid of...
> 
> We need that one (or equivalent) for the runtime PM workqueue at least.

I think Jan was talking about all the WQ_FREEZABLE flags in
filesystem workqueues (such as all the XFS wqs) that are no longer
necessary once filesystems are frozen appropriately.

Cheers,

Dave.
Rafael J. Wysocki Nov. 30, 2017, 11:40 p.m. UTC | #4
On Friday, December 1, 2017 12:30:33 AM CET Dave Chinner wrote:
> On Thu, Nov 30, 2017 at 09:32:53PM +0100, Rafael J. Wysocki wrote:
> > On Thu, Nov 30, 2017 at 5:21 PM, Jan Kara <jack@suse.cz> wrote:
> > > On Wed 29-11-17 15:23:52, Luis R. Rodriguez wrote:
> > >> This removes superflous freezer calls as they are no longer needed
> > >> as the VFS now performs filesystem freezing/thaw if the filesystem has
> > >> support for it.
> > >>
> > >> The following Coccinelle rule was used as follows:
> > >>
> > >> spatch --sp-file fs-freeze-cleanup.cocci --in-place fs/$FS/
> > >
> > > I think your rule misses WQ_FREEZABLE flag for workqueues? That would be
> > > also good to get rid of...
> > 
> > We need that one (or equivalent) for the runtime PM workqueue at least.
> 
> I think Jan was talking about all the WQ_FREEZABLE flags in
> filesystem workqueues (such as all the XFS wqs) that are no longer
> necessary once filesystems are frozen appropriately.

I see, thanks.  That was unclear to me, sorry for the confusion.

Thanks,
Rafael
diff mbox

Patch

diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index cef89f7127d3..1f3dd10a9d00 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -513,7 +513,6 @@  xfsaild(
 	long		tout = 0;	/* milliseconds */
 
 	current->flags |= PF_MEMALLOC;
-	set_freezable();
 
 	while (1) {
 		if (tout && tout <= 20)
@@ -551,19 +550,17 @@  xfsaild(
 		if (!xfs_ail_min(ailp) &&
 		    ailp->xa_target == ailp->xa_target_prev) {
 			spin_unlock(&ailp->xa_lock);
-			freezable_schedule();
+			schedule();
 			tout = 0;
 			continue;
 		}
 		spin_unlock(&ailp->xa_lock);
 
 		if (tout)
-			freezable_schedule_timeout(msecs_to_jiffies(tout));
+			schedule_timeout(msecs_to_jiffies(tout));
 
 		__set_current_state(TASK_RUNNING);
 
-		try_to_freeze();
-
 		tout = xfsaild_push(ailp);
 	}