OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] Use list_first_entry in locks_wake_up_blocks
[PATCH] Use list_first_entry in locks_wake_up_blocks [message #20511] Wed, 19 September 2007 12:44 Go to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
This routine deletes all the elements from the list
with the "while (!list_empty())" loop, and we already
have a list_first_entry() macro to help it look nicer :)

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/fs/locks.c b/fs/locks.c
index 746dc70..5fa072a 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -534,7 +534,9 @@ static void locks_insert_block(struct fi
 static void locks_wake_up_blocks(struct file_lock *blocker)
 {
 	while (!list_empty(&blocker->fl_block)) {
-		struct file_lock *waiter = list_entry(blocker->fl_block.next,
+		struct file_lock *waiter;
+
+		waiter = list_first_entry(&blocker->fl_block,
 				struct file_lock, fl_block);
 		__locks_delete_block(waiter);
 		if (waiter->fl_lmops && waiter->fl_lmops->fl_notify)
Re: [PATCH] Use list_first_entry in locks_wake_up_blocks [message #20521 is a reply to message #20511] Wed, 19 September 2007 19:22 Go to previous message
bfields is currently offline  bfields
Messages: 107
Registered: September 2007
Senior Member
On Wed, Sep 19, 2007 at 04:44:07PM +0400, Pavel Emelyanov wrote:
> This routine deletes all the elements from the list
> with the "while (!list_empty())" loop, and we already
> have a list_first_entry() macro to help it look nicer :)

OK.

--b.

> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
> 
> ---
> 
> diff --git a/fs/locks.c b/fs/locks.c
> index 746dc70..5fa072a 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -534,7 +534,9 @@ static void locks_insert_block(struct fi
>  static void locks_wake_up_blocks(struct file_lock *blocker)
>  {
>  	while (!list_empty(&blocker->fl_block)) {
> -		struct file_lock *waiter = list_entry(blocker->fl_block.next,
> +		struct file_lock *waiter;
> +
> +		waiter = list_first_entry(&blocker->fl_block,
>  				struct file_lock, fl_block);
>  		__locks_delete_block(waiter);
>  		if (waiter->fl_lmops && waiter->fl_lmops->fl_notify)
Previous Topic: [PATCH] Wake up mandatory locks waiter on chmod
Next Topic: [PATCH 2/5][GFS2] Cleanup explicit check for mandatory locks
Goto Forum:
  


Current Time: Wed Aug 07 20:02:37 GMT 2024

Total time taken to generate the page: 0.02672 seconds