Skip to content

Commit 69ca1f5

Browse files
committed
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 Tested-by: Anthony Nandaa (Microsoft) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent cd93650 commit 69ca1f5

File tree

2 files changed

+75
-8
lines changed

2 files changed

+75
-8
lines changed

fs/smb/client/ioctl.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,32 @@ static long smb_mnt_get_fsinfo(unsigned int xid, struct cifs_tcon *tcon,
170170
static int cifs_shutdown(struct super_block *sb, unsigned long arg)
171171
{
172172
struct cifs_sb_info *sbi = CIFS_SB(sb);
173+
struct tcon_link *tlink;
174+
struct cifs_tcon *tcon;
173175
__u32 flags;
176+
int rc;
174177

175178
if (!capable(CAP_SYS_ADMIN))
176179
return -EPERM;
177180

178181
if (get_user(flags, (__u32 __user *)arg))
179182
return -EFAULT;
180183

181-
if (flags > CIFS_GOING_FLAGS_NOLOGFLUSH)
182-
return -EINVAL;
184+
tlink = cifs_sb_tlink(sbi);
185+
if (IS_ERR(tlink))
186+
return PTR_ERR(tlink);
187+
tcon = tlink_tcon(tlink);
188+
189+
trace_smb3_shutdown_enter(flags, tcon->tid);
190+
if (flags > CIFS_GOING_FLAGS_NOLOGFLUSH) {
191+
rc = -EINVAL;
192+
goto shutdown_out_err;
193+
}
183194

184195
if (cifs_forced_shutdown(sbi))
185-
return 0;
196+
goto shutdown_good;
186197

187198
cifs_dbg(VFS, "shut down requested (%d)", flags);
188-
/* trace_cifs_shutdown(sb, flags);*/
189199

190200
/*
191201
* see:
@@ -201,7 +211,8 @@ static int cifs_shutdown(struct super_block *sb, unsigned long arg)
201211
*/
202212
case CIFS_GOING_FLAGS_DEFAULT:
203213
cifs_dbg(FYI, "shutdown with default flag not supported\n");
204-
return -EINVAL;
214+
rc = -EINVAL;
215+
goto shutdown_out_err;
205216
/*
206217
* FLAGS_LOGFLUSH is easy since it asks to write out metadata (not
207218
* data) but metadata writes are not cached on the client, so can treat
@@ -210,11 +221,18 @@ static int cifs_shutdown(struct super_block *sb, unsigned long arg)
210221
case CIFS_GOING_FLAGS_LOGFLUSH:
211222
case CIFS_GOING_FLAGS_NOLOGFLUSH:
212223
sbi->mnt_cifs_flags |= CIFS_MOUNT_SHUTDOWN;
213-
return 0;
224+
goto shutdown_good;
214225
default:
215-
return -EINVAL;
226+
rc = -EINVAL;
227+
goto shutdown_out_err;
216228
}
229+
230+
shutdown_good:
231+
trace_smb3_shutdown_done(flags, tcon->tid);
217232
return 0;
233+
shutdown_out_err:
234+
trace_smb3_shutdown_err(rc, flags, tcon->tid);
235+
return rc;
218236
}
219237

220238
static int cifs_dump_full_key(struct cifs_tcon *tcon, struct smb3_full_key_debug_info __user *in)

fs/smb/client/trace.h

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ DECLARE_EVENT_CLASS(smb3_ioctl_class,
13881388
__entry->command = command;
13891389
),
13901390
TP_printk("xid=%u fid=0x%llx ioctl cmd=0x%x",
1391-
__entry->xid, __entry->fid, __entry->command)
1391+
__entry->xid, __entry->fid, __entry->command)
13921392
)
13931393

13941394
#define DEFINE_SMB3_IOCTL_EVENT(name) \
@@ -1400,9 +1400,58 @@ DEFINE_EVENT(smb3_ioctl_class, smb3_##name, \
14001400

14011401
DEFINE_SMB3_IOCTL_EVENT(ioctl);
14021402

1403+
DECLARE_EVENT_CLASS(smb3_shutdown_class,
1404+
TP_PROTO(__u32 flags,
1405+
__u32 tid),
1406+
TP_ARGS(flags, tid),
1407+
TP_STRUCT__entry(
1408+
__field(__u32, flags)
1409+
__field(__u32, tid)
1410+
),
1411+
TP_fast_assign(
1412+
__entry->flags = flags;
1413+
__entry->tid = tid;
1414+
),
1415+
TP_printk("flags=0x%x tid=0x%x",
1416+
__entry->flags, __entry->tid)
1417+
)
1418+
1419+
#define DEFINE_SMB3_SHUTDOWN_EVENT(name) \
1420+
DEFINE_EVENT(smb3_shutdown_class, smb3_##name, \
1421+
TP_PROTO(__u32 flags, \
1422+
__u32 tid), \
1423+
TP_ARGS(flags, tid))
1424+
1425+
DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_enter);
1426+
DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_done);
14031427

1428+
DECLARE_EVENT_CLASS(smb3_shutdown_err_class,
1429+
TP_PROTO(int rc,
1430+
__u32 flags,
1431+
__u32 tid),
1432+
TP_ARGS(rc, flags, tid),
1433+
TP_STRUCT__entry(
1434+
__field(int, rc)
1435+
__field(__u32, flags)
1436+
__field(__u32, tid)
1437+
),
1438+
TP_fast_assign(
1439+
__entry->rc = rc;
1440+
__entry->flags = flags;
1441+
__entry->tid = tid;
1442+
),
1443+
TP_printk("rc=%d flags=0x%x tid=0x%x",
1444+
__entry->rc, __entry->flags, __entry->tid)
1445+
)
14041446

1447+
#define DEFINE_SMB3_SHUTDOWN_ERR_EVENT(name) \
1448+
DEFINE_EVENT(smb3_shutdown_err_class, smb3_##name, \
1449+
TP_PROTO(int rc, \
1450+
__u32 flags, \
1451+
__u32 tid), \
1452+
TP_ARGS(rc, flags, tid))
14051453

1454+
DEFINE_SMB3_SHUTDOWN_ERR_EVENT(shutdown_err);
14061455

14071456
DECLARE_EVENT_CLASS(smb3_credit_class,
14081457
TP_PROTO(__u64 currmid,

0 commit comments

Comments
 (0)