From patchwork Tue Jul 30 05:34:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13746677 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52CD233D5 for ; Tue, 30 Jul 2024 05:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722317671; cv=none; b=kbzdiU6qHhrGNOv7cQ6pf6g6IBFZDIxtWcshLqqiAQ3Dw6O4VNdx5cq5FbmkBNaNaoV+PTMqSM9jJBxGHOe61RGWE+wI82Lfaqsl0gLTkmmZCFg2wCk1txP1Iwbkr+9LOYaQqMwcmlmyk0BimKUptq0oTPvQFS5IUatdAqpb+JM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722317671; c=relaxed/simple; bh=eECQ5ULEyDbnTHint+4kJiJHno01tnPPBuJkGnQHyyU=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=DFRybVSODf/iwJLDHxnG8RBeijddPJFMNTjz3UMxZrUcG76xQX0gmrO6SIfDihSc2gED5evdUgF+LFN7q/jsV2nVq9o333bzYvpPIuzWE9g69hOKu736vdxr5Tw7my9N318aSvpUZbN7QecHX6ycx7FcDsHQIlQJOLOJM2d9ruY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Qi6MMfHP; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qi6MMfHP" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2ef2d582e31so51094181fa.2 for ; Mon, 29 Jul 2024 22:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722317667; x=1722922467; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=19YrcVfbExCDN8xnesR19+Kpu0uBX9NNvTzVMFyg3tg=; b=Qi6MMfHP+CMnqcGQqAYBY7QkZVqxMsNGVjm5pjoD5+gCpBHlSONgqAX9cwXKk9DblC lgm1i+9smKn4yukf9IxkFiV+c0ovFXrWztOS19+jDTNCOjnKt7Qs7NB2HyDnmFQXqB9z yPRu+65Zu3+cSdNcq/isfx9Lxxw4R1M9ah1JIMDBlBGgnL5OCcPX8uRNeaQT8UUFoD1D s6SCKJVYoePNl9ryWhficMHEFsjqar1W4fscolLeIASt5d5BStBoD2GlvymrfBYNdtXd yrMOBPF7OFDaTX6pix2mjVXDp62qVFPQomTH7ne03oJYuOL+2t0C2Bm7ycvyQZ8a2uDH DYoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722317667; x=1722922467; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=19YrcVfbExCDN8xnesR19+Kpu0uBX9NNvTzVMFyg3tg=; b=OmtyMNci+xk8gg7OJMKB8iolwzqAE59/16D9uPcfYo5gBp/O2mY50pq9+70Y29xjut XIq7H5eR/a+d4fC17yph310QD5nfsb50KGs6iC60K7VdWY6Zg4L4c3oFx5I7SAjmYlcj Xk3J9AbD6azrDn6Wd0qW2fq0m3Hy23g8A286ia7UDae7nXw7Qq+4zOnQsSnPVrJetSvU r5uT0kUnUqv98nH8bLvlW8dOTknKRAZ2vOmwZzHRUCEAZjhJAVRoj95ZS32mf4SY2sid KipmQbcG42zNTbX2h/P8C5AMxZCr2eR7FGzf7B4jlu2lOpXcKQd5PsshhqmzAgCJrNgx +b/g== X-Gm-Message-State: AOJu0YwDKJq8yTt1qZkmgdxCfFjwdjMnWFNrqtVB4f+opneqVahJ7y03 6ptoKFQcGwAh4lhxXqCUaceqFa+gj0zV1j0NpJsg8PxPVWRQw5l6WuuDaH1oJPkhl+SxW4F9nZJ 9/rKtPfspll2CYgh8smYDwzfbc8QxyQYP X-Google-Smtp-Source: AGHT+IEmLgsM40YzHW/ueFQ/wlpk+VoNspG4Z6iuBKs0oSRoL/biWXYD41vH5gSAdeMh+KkPKWAO2a6MZIycuhq+lJ4= X-Received: by 2002:a2e:9619:0:b0:2ef:2e3f:35da with SMTP id 38308e7fff4ca-2f12ee634famr57909211fa.45.1722317666883; Mon, 29 Jul 2024 22:34:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Steve French Date: Tue, 30 Jul 2024 00:34:15 -0500 Message-ID: Subject: [PATCH][SMB3 client] add dynamic tracepoints for shutdown ioctl To: CIFS Cc: Shyam Prasad N , Bharath S M For debugging an umount failure in xfstests generic/043 generic/044 in some configurations, we needed more information on the shutdown ioctl which was suspected of being related to the cause, so tracepoints are added in this patch e.g. "trace-cmd record -e smb3_shutdown_enter -e smb3_shutdown_done -e smb3_shutdown_err" Sample output: godown-47084 [011] ..... 3313.756965: smb3_shutdown_enter: flags=0x1 tid=0x733b3e75 godown-47084 [011] ..... 3313.756968: smb3_shutdown_done: flags=0x1 tid=0x733b3e75 See attached From 0aeae343da69af8c0516b6650312be517d4ff6a8 Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 30 Jul 2024 00:26:21 -0500 Subject: [PATCH] smb3: add dynamic tracepoints for shutdown ioctl For debugging an umount failure in xfstests generic/043 generic/044 in some configurations, we needed more information on the shutdown ioctl which was suspected of being related to the cause, so tracepoints are added in this patch e.g. "trace-cmd record -e smb3_shutdown_enter -e smb3_shutdown_done -e smb3_shutdown_err" Sample output: godown-47084 [011] ..... 3313.756965: smb3_shutdown_enter: flags=0x1 tid=0x733b3e75 godown-47084 [011] ..... 3313.756968: smb3_shutdown_done: flags=0x1 tid=0x733b3e75 Signed-off-by: Steve French --- fs/smb/client/ioctl.c | 38 ++++++++++++++++++++++++-------- fs/smb/client/trace.h | 51 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/fs/smb/client/ioctl.c b/fs/smb/client/ioctl.c index 855ac5a62edf..90bb2c989aab 100644 --- a/fs/smb/client/ioctl.c +++ b/fs/smb/client/ioctl.c @@ -170,22 +170,34 @@ static long smb_mnt_get_fsinfo(unsigned int xid, struct cifs_tcon *tcon, static int cifs_shutdown(struct super_block *sb, unsigned long arg) { struct cifs_sb_info *sbi = CIFS_SB(sb); + struct tcon_link *tlink; + struct cifs_tcon *tcon; __u32 flags; + int rc; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; + if (!capable(CAP_SYS_ADMIN)) { + rc = -EPERM; + goto shutdown_out_err; + } if (get_user(flags, (__u32 __user *)arg)) return -EFAULT; - if (flags > CIFS_GOING_FLAGS_NOLOGFLUSH) - return -EINVAL; + tlink = cifs_sb_tlink(sbi); + if (IS_ERR(tlink)) + return PTR_ERR(tlink); + tcon = tlink_tcon(tlink); + + trace_smb3_shutdown_enter(flags, tcon->tid); + if (flags > CIFS_GOING_FLAGS_NOLOGFLUSH) { + rc = -EINVAL; + goto shutdown_out_err; + } if (cifs_forced_shutdown(sbi)) - return 0; + goto shutdown_good; cifs_dbg(VFS, "shut down requested (%d)", flags); -/* trace_cifs_shutdown(sb, flags);*/ /* * see: @@ -201,7 +213,8 @@ static int cifs_shutdown(struct super_block *sb, unsigned long arg) */ case CIFS_GOING_FLAGS_DEFAULT: cifs_dbg(FYI, "shutdown with default flag not supported\n"); - return -EINVAL; + rc = -EINVAL; + goto shutdown_out_err; /* * FLAGS_LOGFLUSH is easy since it asks to write out metadata (not * data) but metadata writes are not cached on the client, so can treat @@ -210,11 +223,18 @@ static int cifs_shutdown(struct super_block *sb, unsigned long arg) case CIFS_GOING_FLAGS_LOGFLUSH: case CIFS_GOING_FLAGS_NOLOGFLUSH: sbi->mnt_cifs_flags |= CIFS_MOUNT_SHUTDOWN; - return 0; + goto shutdown_good; default: - return -EINVAL; + rc = -EINVAL; + goto shutdown_out_err; } + +shutdown_good: + trace_smb3_shutdown_done(flags, tcon->tid); return 0; +shutdown_out_err: + trace_smb3_shutdown_err(rc, flags, tcon->tid); + return rc; } static int cifs_dump_full_key(struct cifs_tcon *tcon, struct smb3_full_key_debug_info __user *in) diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h index 6b3bdfb97211..0f0c10c7ada7 100644 --- a/fs/smb/client/trace.h +++ b/fs/smb/client/trace.h @@ -1388,7 +1388,7 @@ DECLARE_EVENT_CLASS(smb3_ioctl_class, __entry->command = command; ), TP_printk("xid=%u fid=0x%llx ioctl cmd=0x%x", - __entry->xid, __entry->fid, __entry->command) + __entry->xid, __entry->fid, __entry->command) ) #define DEFINE_SMB3_IOCTL_EVENT(name) \ @@ -1400,9 +1400,58 @@ DEFINE_EVENT(smb3_ioctl_class, smb3_##name, \ DEFINE_SMB3_IOCTL_EVENT(ioctl); +DECLARE_EVENT_CLASS(smb3_shutdown_class, + TP_PROTO(__u32 flags, + __u32 tid), + TP_ARGS(flags, tid), + TP_STRUCT__entry( + __field(__u32, flags) + __field(__u32, tid) + ), + TP_fast_assign( + __entry->flags = flags; + __entry->tid = tid; + ), + TP_printk("flags=0x%x tid=0x%x", + __entry->flags, __entry->tid) +) + +#define DEFINE_SMB3_SHUTDOWN_EVENT(name) \ +DEFINE_EVENT(smb3_shutdown_class, smb3_##name, \ + TP_PROTO(__u32 flags, \ + __u32 tid), \ + TP_ARGS(flags, tid)) + +DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_enter); +DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_done); +DECLARE_EVENT_CLASS(smb3_shutdown_err_class, + TP_PROTO(int rc, + __u32 flags, + __u32 tid), + TP_ARGS(rc, flags, tid), + TP_STRUCT__entry( + __field(int, rc) + __field(__u32, flags) + __field(__u32, tid) + ), + TP_fast_assign( + __entry->rc = rc; + __entry->flags = flags; + __entry->tid = tid; + ), + TP_printk("rc=%d flags=0x%x tid=0x%x", + __entry->rc, __entry->flags, __entry->tid) +) +#define DEFINE_SMB3_SHUTDOWN_ERR_EVENT(name) \ +DEFINE_EVENT(smb3_shutdown_err_class, smb3_##name, \ + TP_PROTO(int rc, \ + __u32 flags, \ + __u32 tid), \ + TP_ARGS(rc, flags, tid)) +DEFINE_SMB3_SHUTDOWN_ERR_EVENT(shutdown_err); DECLARE_EVENT_CLASS(smb3_credit_class, TP_PROTO(__u64 currmid, -- 2.43.0