diff mbox

[2/9] dm: Rename a function argument

Message ID 0753eed4-ba3a-a747-648d-cd5520916134@sandisk.com (mailing list archive)
State Superseded, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Bart Van Assche Aug. 31, 2016, 10:16 p.m. UTC
Rename 'interruptible' into 'sleep_state' to make it clear that this
argument is a task state instead of a boolean.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 drivers/md/dm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Mike Snitzer Sept. 1, 2016, 3:29 a.m. UTC | #1
On Wed, Aug 31 2016 at  6:16pm -0400,
Bart Van Assche <bart.vanassche@sandisk.com> wrote:

> Rename 'interruptible' into 'sleep_state' to make it clear that this
> argument is a task state instead of a boolean.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>

Shouldn't the type also be changed from int to long (to match 'state'
member from 'struct task_struct')?

> ---
>  drivers/md/dm.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index fa9b1cb..1d3627c 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1934,7 +1934,8 @@ void dm_put(struct mapped_device *md)
>  }
>  EXPORT_SYMBOL_GPL(dm_put);
>  
> -static int dm_wait_for_completion(struct mapped_device *md, int interruptible)
> +/* @sleep_state: e.g. TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE */
> +static int dm_wait_for_completion(struct mapped_device *md, int sleep_state)
>  {
>  	int r = 0;
>  	DECLARE_WAITQUEUE(wait, current);
> @@ -1942,12 +1943,12 @@ static int dm_wait_for_completion(struct mapped_device *md, int interruptible)
>  	add_wait_queue(&md->wait, &wait);
>  
>  	while (1) {
> -		set_current_state(interruptible);
> +		set_current_state(sleep_state);
>  
>  		if (!md_in_flight(md))
>  			break;
>  
> -		if (interruptible == TASK_INTERRUPTIBLE &&
> +		if (sleep_state == TASK_INTERRUPTIBLE &&
>  		    signal_pending(current)) {
>  			r = -EINTR;
>  			break;
> @@ -2075,6 +2076,10 @@ static void unlock_fs(struct mapped_device *md)
>  }
>  
>  /*
> + * @suspend_flags: DM_SUSPEND_LOCKFS_FLAG and/or DM_SUSPEND_NOFLUSH_FLAG
> + * @sleep_state: e.g. TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE
> + * @dmf_suspended_flag: DMF_SUSPENDED or DMF_SUSPENDED_INTERNALLY
> + *
>   * If __dm_suspend returns 0, the device is completely quiescent
>   * now. There is no request-processing activity. All new requests
>   * are being added to md->deferred list.
> @@ -2082,7 +2087,7 @@ static void unlock_fs(struct mapped_device *md)
>   * Caller must hold md->suspend_lock
>   */
>  static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
> -			unsigned suspend_flags, int interruptible,
> +			unsigned suspend_flags, int sleep_state,
>  			int dmf_suspended_flag)
>  {
>  	bool do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG;
> @@ -2149,7 +2154,7 @@ static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
>  	 * We call dm_wait_for_completion to wait for all existing requests
>  	 * to finish.
>  	 */
> -	r = dm_wait_for_completion(md, interruptible);
> +	r = dm_wait_for_completion(md, sleep_state);
>  	if (!r)
>  		set_bit(dmf_suspended_flag, &md->flags);
>  
> -- 
> 2.9.3
> 
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Bart Van Assche Sept. 1, 2016, 2:17 p.m. UTC | #2
On 08/31/16 20:29, Mike Snitzer wrote:
> On Wed, Aug 31 2016 at  6:16pm -0400,
> Bart Van Assche <bart.vanassche@sandisk.com> wrote:
>
>> Rename 'interruptible' into 'sleep_state' to make it clear that this
>> argument is a task state instead of a boolean.
>
> Shouldn't the type also be changed from int to long (to match 'state'
> member from 'struct task_struct')?

Hello Mike,

Today TASK_STATE_MAX equals 2048. So I think an int is big enough even 
on 32-bit platforms. Please let me know if you really want me to change 
the type from int to long.

Bart.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index fa9b1cb..1d3627c 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1934,7 +1934,8 @@  void dm_put(struct mapped_device *md)
 }
 EXPORT_SYMBOL_GPL(dm_put);
 
-static int dm_wait_for_completion(struct mapped_device *md, int interruptible)
+/* @sleep_state: e.g. TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE */
+static int dm_wait_for_completion(struct mapped_device *md, int sleep_state)
 {
 	int r = 0;
 	DECLARE_WAITQUEUE(wait, current);
@@ -1942,12 +1943,12 @@  static int dm_wait_for_completion(struct mapped_device *md, int interruptible)
 	add_wait_queue(&md->wait, &wait);
 
 	while (1) {
-		set_current_state(interruptible);
+		set_current_state(sleep_state);
 
 		if (!md_in_flight(md))
 			break;
 
-		if (interruptible == TASK_INTERRUPTIBLE &&
+		if (sleep_state == TASK_INTERRUPTIBLE &&
 		    signal_pending(current)) {
 			r = -EINTR;
 			break;
@@ -2075,6 +2076,10 @@  static void unlock_fs(struct mapped_device *md)
 }
 
 /*
+ * @suspend_flags: DM_SUSPEND_LOCKFS_FLAG and/or DM_SUSPEND_NOFLUSH_FLAG
+ * @sleep_state: e.g. TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE
+ * @dmf_suspended_flag: DMF_SUSPENDED or DMF_SUSPENDED_INTERNALLY
+ *
  * If __dm_suspend returns 0, the device is completely quiescent
  * now. There is no request-processing activity. All new requests
  * are being added to md->deferred list.
@@ -2082,7 +2087,7 @@  static void unlock_fs(struct mapped_device *md)
  * Caller must hold md->suspend_lock
  */
 static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
-			unsigned suspend_flags, int interruptible,
+			unsigned suspend_flags, int sleep_state,
 			int dmf_suspended_flag)
 {
 	bool do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG;
@@ -2149,7 +2154,7 @@  static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
 	 * We call dm_wait_for_completion to wait for all existing requests
 	 * to finish.
 	 */
-	r = dm_wait_for_completion(md, interruptible);
+	r = dm_wait_for_completion(md, sleep_state);
 	if (!r)
 		set_bit(dmf_suspended_flag, &md->flags);