linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] fsfreeze: wait in killable state in __sb_start_write
@ 2013-04-26  8:49 Marco Stornelli
  0 siblings, 0 replies; 4+ messages in thread
From: Marco Stornelli @ 2013-04-26  8:49 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Alexander Viro, linux-kernel, Jan Kara

Added a new enum to decide if we want to sleep in uninterruptible or
killable state or we want simply to return immediately.

Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/super.c         |   24 ++++++++++++++++++------
 include/linux/fs.h |   19 +++++++++++++------
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 7465d43..6b70c7f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1190,14 +1190,25 @@ static void acquire_freeze_lock(struct super_block *sb, int level, bool trylock,
  * This is an internal function, please use sb_start_{write,pagefault,intwrite}
  * instead.
  */
-int __sb_start_write(struct super_block *sb, int level, bool wait)
+int __sb_start_write(struct super_block *sb, int level, int wait)
 {
+	int ret = 0;
 retry:
 	if (unlikely(sb->s_writers.frozen >= level)) {
-		if (!wait)
-			return 0;
-		wait_event(sb->s_writers.wait_unfrozen,
-			   sb->s_writers.frozen < level);
+		switch (wait) {
+		case FREEZE_NOWAIT:
+			return ret;
+		case FREEZE_WAIT:
+			wait_event(sb->s_writers.wait_unfrozen,
+				   sb->s_writers.frozen < level);
+			break;
+		case FREEZE_WAIT_KILLABLE:
+			ret = wait_event_killable(sb->s_writers.wait_unfrozen,
+				   sb->s_writers.frozen < level);
+			if (ret)
+				return -EINTR;
+			break;
+		}
 	}
 
 #ifdef CONFIG_LOCKDEP
@@ -1213,7 +1224,8 @@ retry:
 		__sb_end_write(sb, level);
 		goto retry;
 	}
-	return 1;
+	ret = 1;
+	return ret;
 }
 EXPORT_SYMBOL(__sb_start_write);
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8d47c9a..c8b7325 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1220,6 +1220,13 @@ enum {
 
 #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1)
 
+/* Possible waiting modes */
+enum {
+	FREEZE_NOWAIT = 0,		/* no blocking call */
+	FREEZE_WAIT	= 1,		/* wait in uninterruptible state */
+	FREEZE_WAIT_KILLABLE = 2,	/* wait in killable state */
+};
+
 struct sb_writers {
 	/* Counters for counting writers at each level */
 	struct percpu_counter	counter[SB_FREEZE_LEVELS];
@@ -1335,7 +1342,7 @@ extern struct timespec current_fs_time(struct super_block *sb);
  */
 
 void __sb_end_write(struct super_block *sb, int level);
-int __sb_start_write(struct super_block *sb, int level, bool wait);
+int __sb_start_write(struct super_block *sb, int level, int wait);
 
 /**
  * sb_end_write - drop write access to a superblock
@@ -1394,12 +1401,12 @@ static inline void sb_end_intwrite(struct super_block *sb)
  */
 static inline void sb_start_write(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_WRITE, true);
+	__sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_WAIT);
 }
 
 static inline int sb_start_write_trylock(struct super_block *sb)
 {
-	return __sb_start_write(sb, SB_FREEZE_WRITE, false);
+	return __sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_NOWAIT);
 }
 
 /**
@@ -1423,7 +1430,7 @@ static inline int sb_start_write_trylock(struct super_block *sb)
  */
 static inline void sb_start_pagefault(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, true);
+	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, FREEZE_WAIT);
 }
 
 /*
@@ -1441,7 +1448,7 @@ static inline void sb_start_pagefault(struct super_block *sb)
  */
 static inline void sb_start_intwrite(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_FS, true);
+	__sb_start_write(sb, SB_FREEZE_FS, FREEZE_WAIT);
 }
 
 
@@ -2224,7 +2231,7 @@ static inline void file_start_write(struct file *file)
 {
 	if (!S_ISREG(file_inode(file)->i_mode))
 		return;
-	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
+	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, FREEZE_WAIT);
 }
 
 static inline void file_end_write(struct file *file)
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 1/4] fsfreeze: wait in killable state in __sb_start_write
@ 2013-05-04  6:49 Marco Stornelli
  2013-05-18  7:32 ` Marco
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Stornelli @ 2013-05-04  6:49 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Alexander Viro, Matthew Wilcox, linux-kernel, Jan Kara

Added a new enum to decide if we want to sleep in uninterruptible or
killable state or we want simply to return immediately.

Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/super.c         |   24 ++++++++++++++++++------
 include/linux/fs.h |   19 +++++++++++++------
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 7465d43..6b70c7f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1190,14 +1190,25 @@ static void acquire_freeze_lock(struct super_block *sb, int level, bool trylock,
  * This is an internal function, please use sb_start_{write,pagefault,intwrite}
  * instead.
  */
-int __sb_start_write(struct super_block *sb, int level, bool wait)
+int __sb_start_write(struct super_block *sb, int level, int wait)
 {
+	int ret = 0;
 retry:
 	if (unlikely(sb->s_writers.frozen >= level)) {
-		if (!wait)
-			return 0;
-		wait_event(sb->s_writers.wait_unfrozen,
-			   sb->s_writers.frozen < level);
+		switch (wait) {
+		case FREEZE_NOWAIT:
+			return ret;
+		case FREEZE_WAIT:
+			wait_event(sb->s_writers.wait_unfrozen,
+				   sb->s_writers.frozen < level);
+			break;
+		case FREEZE_WAIT_KILLABLE:
+			ret = wait_event_killable(sb->s_writers.wait_unfrozen,
+				   sb->s_writers.frozen < level);
+			if (ret)
+				return -EINTR;
+			break;
+		}
 	}
 
 #ifdef CONFIG_LOCKDEP
@@ -1213,7 +1224,8 @@ retry:
 		__sb_end_write(sb, level);
 		goto retry;
 	}
-	return 1;
+	ret = 1;
+	return ret;
 }
 EXPORT_SYMBOL(__sb_start_write);
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e8cd6b8..6d9bcef 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1220,6 +1220,13 @@ enum {
 
 #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1)
 
+/* Possible waiting modes */
+enum {
+	FREEZE_NOWAIT = 0,		/* no blocking call */
+	FREEZE_WAIT	= 1,		/* wait in uninterruptible state */
+	FREEZE_WAIT_KILLABLE = 2,	/* wait in killable state */
+};
+
 struct sb_writers {
 	/* Counters for counting writers at each level */
 	struct percpu_counter	counter[SB_FREEZE_LEVELS];
@@ -1335,7 +1342,7 @@ extern struct timespec current_fs_time(struct super_block *sb);
  */
 
 void __sb_end_write(struct super_block *sb, int level);
-int __sb_start_write(struct super_block *sb, int level, bool wait);
+int __sb_start_write(struct super_block *sb, int level, int wait);
 
 /**
  * sb_end_write - drop write access to a superblock
@@ -1394,12 +1401,12 @@ static inline void sb_end_intwrite(struct super_block *sb)
  */
 static inline void sb_start_write(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_WRITE, true);
+	__sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_WAIT);
 }
 
 static inline int sb_start_write_trylock(struct super_block *sb)
 {
-	return __sb_start_write(sb, SB_FREEZE_WRITE, false);
+	return __sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_NOWAIT);
 }
 
 /**
@@ -1423,7 +1430,7 @@ static inline int sb_start_write_trylock(struct super_block *sb)
  */
 static inline void sb_start_pagefault(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, true);
+	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, FREEZE_WAIT);
 }
 
 /*
@@ -1441,7 +1448,7 @@ static inline void sb_start_pagefault(struct super_block *sb)
  */
 static inline void sb_start_intwrite(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_FS, true);
+	__sb_start_write(sb, SB_FREEZE_FS, FREEZE_WAIT);
 }
 
 
@@ -2224,7 +2231,7 @@ static inline void file_start_write(struct file *file)
 {
 	if (!S_ISREG(file_inode(file)->i_mode))
 		return;
-	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
+	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, FREEZE_WAIT);
 }
 
 static inline void file_end_write(struct file *file)
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/4] fsfreeze: wait in killable state in __sb_start_write
  2013-05-04  6:49 [PATCH 1/4] fsfreeze: wait in killable state in __sb_start_write Marco Stornelli
@ 2013-05-18  7:32 ` Marco
  0 siblings, 0 replies; 4+ messages in thread
From: Marco @ 2013-05-18  7:32 UTC (permalink / raw)
  To: Linux FS Devel; +Cc: linux-kernel, Jan Kara

Any comments about these patches?

Marco

Il 04/05/2013 08:49, Marco Stornelli ha scritto:
> Added a new enum to decide if we want to sleep in uninterruptible or
> killable state or we want simply to return immediately.
>
> Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
>   fs/super.c         |   24 ++++++++++++++++++------
>   include/linux/fs.h |   19 +++++++++++++------
>   2 files changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index 7465d43..6b70c7f 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1190,14 +1190,25 @@ static void acquire_freeze_lock(struct super_block *sb, int level, bool trylock,
>    * This is an internal function, please use sb_start_{write,pagefault,intwrite}
>    * instead.
>    */
> -int __sb_start_write(struct super_block *sb, int level, bool wait)
> +int __sb_start_write(struct super_block *sb, int level, int wait)
>   {
> +	int ret = 0;
>   retry:
>   	if (unlikely(sb->s_writers.frozen >= level)) {
> -		if (!wait)
> -			return 0;
> -		wait_event(sb->s_writers.wait_unfrozen,
> -			   sb->s_writers.frozen < level);
> +		switch (wait) {
> +		case FREEZE_NOWAIT:
> +			return ret;
> +		case FREEZE_WAIT:
> +			wait_event(sb->s_writers.wait_unfrozen,
> +				   sb->s_writers.frozen < level);
> +			break;
> +		case FREEZE_WAIT_KILLABLE:
> +			ret = wait_event_killable(sb->s_writers.wait_unfrozen,
> +				   sb->s_writers.frozen < level);
> +			if (ret)
> +				return -EINTR;
> +			break;
> +		}
>   	}
>
>   #ifdef CONFIG_LOCKDEP
> @@ -1213,7 +1224,8 @@ retry:
>   		__sb_end_write(sb, level);
>   		goto retry;
>   	}
> -	return 1;
> +	ret = 1;
> +	return ret;
>   }
>   EXPORT_SYMBOL(__sb_start_write);
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index e8cd6b8..6d9bcef 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1220,6 +1220,13 @@ enum {
>
>   #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1)
>
> +/* Possible waiting modes */
> +enum {
> +	FREEZE_NOWAIT = 0,		/* no blocking call */
> +	FREEZE_WAIT	= 1,		/* wait in uninterruptible state */
> +	FREEZE_WAIT_KILLABLE = 2,	/* wait in killable state */
> +};
> +
>   struct sb_writers {
>   	/* Counters for counting writers at each level */
>   	struct percpu_counter	counter[SB_FREEZE_LEVELS];
> @@ -1335,7 +1342,7 @@ extern struct timespec current_fs_time(struct super_block *sb);
>    */
>
>   void __sb_end_write(struct super_block *sb, int level);
> -int __sb_start_write(struct super_block *sb, int level, bool wait);
> +int __sb_start_write(struct super_block *sb, int level, int wait);
>
>   /**
>    * sb_end_write - drop write access to a superblock
> @@ -1394,12 +1401,12 @@ static inline void sb_end_intwrite(struct super_block *sb)
>    */
>   static inline void sb_start_write(struct super_block *sb)
>   {
> -	__sb_start_write(sb, SB_FREEZE_WRITE, true);
> +	__sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_WAIT);
>   }
>
>   static inline int sb_start_write_trylock(struct super_block *sb)
>   {
> -	return __sb_start_write(sb, SB_FREEZE_WRITE, false);
> +	return __sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_NOWAIT);
>   }
>
>   /**
> @@ -1423,7 +1430,7 @@ static inline int sb_start_write_trylock(struct super_block *sb)
>    */
>   static inline void sb_start_pagefault(struct super_block *sb)
>   {
> -	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, true);
> +	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, FREEZE_WAIT);
>   }
>
>   /*
> @@ -1441,7 +1448,7 @@ static inline void sb_start_pagefault(struct super_block *sb)
>    */
>   static inline void sb_start_intwrite(struct super_block *sb)
>   {
> -	__sb_start_write(sb, SB_FREEZE_FS, true);
> +	__sb_start_write(sb, SB_FREEZE_FS, FREEZE_WAIT);
>   }
>
>
> @@ -2224,7 +2231,7 @@ static inline void file_start_write(struct file *file)
>   {
>   	if (!S_ISREG(file_inode(file)->i_mode))
>   		return;
> -	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
> +	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, FREEZE_WAIT);
>   }
>
>   static inline void file_end_write(struct file *file)
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/4] fsfreeze: wait in killable state in __sb_start_write
@ 2013-07-04 16:15 Gmail
  0 siblings, 0 replies; 4+ messages in thread
From: Gmail @ 2013-07-04 16:15 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Alexander Viro, linux-kernel

Added a new enum to decide if we want to sleep in uninterruptible or
killable state or we want simply to return immediately.

Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/super.c         |   24 ++++++++++++++++++------
 include/linux/fs.h |   21 ++++++++++++++-------
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 7465d43..6b70c7f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1190,14 +1190,25 @@ static void acquire_freeze_lock(struct super_block *sb, int level, bool trylock,
  * This is an internal function, please use sb_start_{write,pagefault,intwrite}
  * instead.
  */
-int __sb_start_write(struct super_block *sb, int level, bool wait)
+int __sb_start_write(struct super_block *sb, int level, int wait)
 {
+	int ret = 0;
 retry:
 	if (unlikely(sb->s_writers.frozen >= level)) {
-		if (!wait)
-			return 0;
-		wait_event(sb->s_writers.wait_unfrozen,
-			   sb->s_writers.frozen < level);
+		switch (wait) {
+		case FREEZE_NOWAIT:
+			return ret;
+		case FREEZE_WAIT:
+			wait_event(sb->s_writers.wait_unfrozen,
+				   sb->s_writers.frozen < level);
+			break;
+		case FREEZE_WAIT_KILLABLE:
+			ret = wait_event_killable(sb->s_writers.wait_unfrozen,
+				   sb->s_writers.frozen < level);
+			if (ret)
+				return -EINTR;
+			break;
+		}
 	}
 
 #ifdef CONFIG_LOCKDEP
@@ -1213,7 +1224,8 @@ retry:
 		__sb_end_write(sb, level);
 		goto retry;
 	}
-	return 1;
+	ret = 1;
+	return ret;
 }
 EXPORT_SYMBOL(__sb_start_write);
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 43db02e..1c75053 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1220,6 +1220,13 @@ enum {
 
 #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1)
 
+/* Possible waiting modes */
+enum {
+	FREEZE_NOWAIT = 0,		/* no blocking call */
+	FREEZE_WAIT	= 1,		/* wait in uninterruptible state */
+	FREEZE_WAIT_KILLABLE = 2,	/* wait in killable state */
+};
+
 struct sb_writers {
 	/* Counters for counting writers at each level */
 	struct percpu_counter	counter[SB_FREEZE_LEVELS];
@@ -1335,7 +1342,7 @@ extern struct timespec current_fs_time(struct super_block *sb);
  */
 
 void __sb_end_write(struct super_block *sb, int level);
-int __sb_start_write(struct super_block *sb, int level, bool wait);
+int __sb_start_write(struct super_block *sb, int level, int wait);
 
 /**
  * sb_end_write - drop write access to a superblock
@@ -1394,12 +1401,12 @@ static inline void sb_end_intwrite(struct super_block *sb)
  */
 static inline void sb_start_write(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_WRITE, true);
+	__sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_WAIT);
 }
 
 static inline int sb_start_write_trylock(struct super_block *sb)
 {
-	return __sb_start_write(sb, SB_FREEZE_WRITE, false);
+	return __sb_start_write(sb, SB_FREEZE_WRITE, FREEZE_NOWAIT);
 }
 
 /**
@@ -1423,7 +1430,7 @@ static inline int sb_start_write_trylock(struct super_block *sb)
  */
 static inline void sb_start_pagefault(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, true);
+	__sb_start_write(sb, SB_FREEZE_PAGEFAULT, FREEZE_WAIT);
 }
 
 /*
@@ -1441,7 +1448,7 @@ static inline void sb_start_pagefault(struct super_block *sb)
  */
 static inline void sb_start_intwrite(struct super_block *sb)
 {
-	__sb_start_write(sb, SB_FREEZE_FS, true);
+	__sb_start_write(sb, SB_FREEZE_FS, FREEZE_WAIT);
 }
 
 
@@ -2224,14 +2231,14 @@ static inline void file_start_write(struct file *file)
 {
 	if (!S_ISREG(file_inode(file)->i_mode))
 		return;
-	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
+	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, FREEZE_WAIT);
 }
 
 static inline bool file_start_write_trylock(struct file *file)
 {
 	if (!S_ISREG(file_inode(file)->i_mode))
 		return true;
-	return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false);
+	return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, FREEZE_NOWAIT);
 }
 
 static inline void file_end_write(struct file *file)
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-04 16:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-04  6:49 [PATCH 1/4] fsfreeze: wait in killable state in __sb_start_write Marco Stornelli
2013-05-18  7:32 ` Marco
  -- strict thread matches above, loose matches on Subject: below --
2013-07-04 16:15 Gmail
2013-04-26  8:49 Marco Stornelli

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).