linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: record task name which froze superblock
@ 2015-02-14 18:55 Alexey Dobriyan
  2015-02-16  9:38 ` Jan Kara
  0 siblings, 1 reply; 16+ messages in thread
From: Alexey Dobriyan @ 2015-02-14 18:55 UTC (permalink / raw)
  To: akpm, viro; +Cc: linux-kernel, jack, linux-fsdevel, swhiteho, cluster-devel

Freezing and thawing are separate system calls, task which is supposed
to thaw filesystem/superblock can disappear due to crash or not thaw
due to a bug. Record at least task name (we can't take task_struct
reference) to make support engineer's life easier.

Hopefully 16 bytes per superblock isn't much.

P.S.: Cc'ing GFS2 people just in case they want to correct
my understanding of GFS2 having async freeze code.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/ioctl.c         |   22 ++++++++++++++++------
 fs/super.c         |    2 ++
 include/linux/fs.h |    2 ++
 3 files changed, 20 insertions(+), 6 deletions(-)

--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -518,6 +518,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
 static int ioctl_fsfreeze(struct file *filp)
 {
 	struct super_block *sb = file_inode(filp)->i_sb;
+	int rv;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -527,22 +528,31 @@ static int ioctl_fsfreeze(struct file *filp)
 		return -EOPNOTSUPP;
 
 	/* Freeze */
-	if (sb->s_op->freeze_super)
-		return sb->s_op->freeze_super(sb);
-	return freeze_super(sb);
+	if (sb->s_op->freeze_super) {
+		rv = sb->s_op->freeze_super(sb);
+		if (rv == 0)
+			get_task_comm(sb->s_writers.freeze_comm, current);
+	} else
+		rv = freeze_super(sb);
+	return rv;
 }
 
 static int ioctl_fsthaw(struct file *filp)
 {
 	struct super_block *sb = file_inode(filp)->i_sb;
+	int rv;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
 	/* Thaw */
-	if (sb->s_op->thaw_super)
-		return sb->s_op->thaw_super(sb);
-	return thaw_super(sb);
+	if (sb->s_op->thaw_super) {
+		rv = sb->s_op->thaw_super(sb);
+		if (rv == 0)
+			memset(sb->s_writers.freeze_comm, 0, TASK_COMM_LEN);
+	} else
+		rv = thaw_super(sb);
+	return rv;
 }
 
 /*
--- a/fs/super.c
+++ b/fs/super.c
@@ -1355,6 +1355,7 @@ int freeze_super(struct super_block *sb)
 	 * sees write activity when frozen is set to SB_FREEZE_COMPLETE.
 	 */
 	sb->s_writers.frozen = SB_FREEZE_COMPLETE;
+	get_task_comm(sb->s_writers.freeze_comm, current);
 	up_write(&sb->s_umount);
 	return 0;
 }
@@ -1391,6 +1392,7 @@ int thaw_super(struct super_block *sb)
 
 out:
 	sb->s_writers.frozen = SB_UNFROZEN;
+	memset(sb->s_writers.freeze_comm, 0, TASK_COMM_LEN);
 	smp_wmb();
 	wake_up(&sb->s_writers.wait_unfrozen);
 	deactivate_locked_super(sb);
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1221,6 +1221,8 @@ struct sb_writers {
 	int			frozen;		/* Is sb frozen? */
 	wait_queue_head_t	wait_unfrozen;	/* queue for waiting for
 						   sb to be thawed */
+	/* who froze superblock */
+	char			freeze_comm[16];
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 	struct lockdep_map	lock_map[SB_FREEZE_LEVELS];
 #endif

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

end of thread, other threads:[~2015-03-09 15:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-14 18:55 [PATCH] fs: record task name which froze superblock Alexey Dobriyan
2015-02-16  9:38 ` Jan Kara
2015-02-18  7:34   ` Alexey Dobriyan
2015-02-18  7:36     ` [PATCH v2] " Alexey Dobriyan
2015-02-18  9:13     ` [PATCH] " Jan Kara
2015-02-18 10:18       ` Steven Whitehouse
2015-02-20 11:42       ` Alexey Dobriyan
2015-02-20 12:15         ` Jan Kara
2015-02-28 14:22           ` Alexey Dobriyan
2015-02-28 14:25             ` [PATCH v3] " Alexey Dobriyan
2015-02-28 21:31               ` Dave Chinner
2015-03-02  4:38                 ` Mateusz Guzik
2015-03-02  4:46                   ` Mateusz Guzik
2015-03-09 15:14                     ` Alexey Dobriyan
2015-03-02 21:33                   ` Dave Chinner
2015-03-04 15:14                   ` Alexey Dobriyan

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