From patchwork Sat Feb 14 18:55:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 5828781 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 40EDA9F30C for ; Sat, 14 Feb 2015 18:55:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 541E9201EF for ; Sat, 14 Feb 2015 18:55:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2129F201C8 for ; Sat, 14 Feb 2015 18:55:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754170AbbBNSza (ORCPT ); Sat, 14 Feb 2015 13:55:30 -0500 Received: from mail-we0-f169.google.com ([74.125.82.169]:56785 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754091AbbBNSz3 (ORCPT ); Sat, 14 Feb 2015 13:55:29 -0500 Received: by mail-we0-f169.google.com with SMTP id k48so22407557wev.0; Sat, 14 Feb 2015 10:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=hymyPN+MsmZq8TPeQCJ8SAXLwoUOfgAlqYFioycwLzU=; b=I+AvLEWjZQvIOXxTC/e3RLXN1ypNziTJIZ9JV9J0FE8fRPONTV+Q2cgaopTVQ3OZoG oKmUWRhuOp8Ymv59EFv5UUr/Ov7HaUDSIqMOoCkl5gqv1AFt0D5KWXFAX50DDVb/gzKH utwtxPe3O4ziZ2tQO/fqKW+Qe1ZS4HLIrxcl1rIDVEe9EX6GUAx4I5G0AMnpOpdwTdWM zbHxJkqYcfDxdX1L0Cx8Qu2Td3V13B2L6Fw9oj9dCO5C0cxxQn4V7lrMSRSUay7PInbJ zOQH9AeHXDRvNuaC10h/XvzFdVsf9UDjyA6DOdf92ebOi9RDvFlMF90qY3vyN7Mmkd0e R5Ew== X-Received: by 10.194.60.77 with SMTP id f13mr32800082wjr.105.1423940128242; Sat, 14 Feb 2015 10:55:28 -0800 (PST) Received: from p183.telecom.by (nat4-minsk-pool-46-53-177-222.telecom.by. [46.53.177.222]) by mx.google.com with ESMTPSA id lj13sm12096776wic.9.2015.02.14.10.55.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Feb 2015 10:55:27 -0800 (PST) Date: Sat, 14 Feb 2015 21:55:24 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org, viro@zeniv.linux.org.uk Cc: linux-kernel@vger.kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, swhiteho@redhat.com, cluster-devel@redhat.com Subject: [PATCH] fs: record task name which froze superblock Message-ID: <20150214185524.GA16579@p183.telecom.by> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- fs/ioctl.c | 22 ++++++++++++++++------ fs/super.c | 2 ++ include/linux/fs.h | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 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