smb3: add dynamic tracepoint for reflink errors

There are cases where debugging clone_range ("smb2_duplicate_extents"
function) and in the future copy_range ("smb2_copychunk_range") can
be helpful. Add dynamic trace points for any errors in clone, and
a followon patch will add them for copychunk.

"trace-cmd record -e smb3_clone_err"

Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

+62
+5
fs/smb/client/smb2ops.c
··· 2075 cifs_dbg(FYI, "Non-zero response length in duplicate extents\n"); 2076 2077 duplicate_extents_out: 2078 return rc; 2079 } 2080
··· 2075 cifs_dbg(FYI, "Non-zero response length in duplicate extents\n"); 2076 2077 duplicate_extents_out: 2078 + if (rc) 2079 + trace_smb3_clone_err(xid, srcfile->fid.volatile_fid, 2080 + trgtfile->fid.volatile_fid, 2081 + tcon->tid, tcon->ses->Suid, src_off, 2082 + dest_off, len, rc); 2083 return rc; 2084 } 2085
+57
fs/smb/client/trace.h
··· 206 DEFINE_SMB3_OTHER_ERR_EVENT(zero_err); 207 DEFINE_SMB3_OTHER_ERR_EVENT(falloc_err); 208 209 210 /* For logging successful read or write */ 211 DECLARE_EVENT_CLASS(smb3_rw_done_class,
··· 206 DEFINE_SMB3_OTHER_ERR_EVENT(zero_err); 207 DEFINE_SMB3_OTHER_ERR_EVENT(falloc_err); 208 209 + /* 210 + * For logging errors in reflink and copy_range ops e.g. smb2_copychunk_range 211 + * and smb2_duplicate_extents 212 + */ 213 + DECLARE_EVENT_CLASS(smb3_copy_range_err_class, 214 + TP_PROTO(unsigned int xid, 215 + __u64 src_fid, 216 + __u64 target_fid, 217 + __u32 tid, 218 + __u64 sesid, 219 + __u64 src_offset, 220 + __u64 target_offset, 221 + __u32 len, 222 + int rc), 223 + TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len, rc), 224 + TP_STRUCT__entry( 225 + __field(unsigned int, xid) 226 + __field(__u64, src_fid) 227 + __field(__u64, target_fid) 228 + __field(__u32, tid) 229 + __field(__u64, sesid) 230 + __field(__u64, src_offset) 231 + __field(__u64, target_offset) 232 + __field(__u32, len) 233 + __field(int, rc) 234 + ), 235 + TP_fast_assign( 236 + __entry->xid = xid; 237 + __entry->src_fid = src_fid; 238 + __entry->target_fid = target_fid; 239 + __entry->tid = tid; 240 + __entry->sesid = sesid; 241 + __entry->src_offset = src_offset; 242 + __entry->target_offset = target_offset; 243 + __entry->len = len; 244 + __entry->rc = rc; 245 + ), 246 + TP_printk("\txid=%u sid=0x%llx tid=0x%x source fid=0x%llx source offset=0x%llx target fid=0x%llx target offset=0x%llx len=0x%x rc=%d", 247 + __entry->xid, __entry->sesid, __entry->tid, __entry->target_fid, 248 + __entry->src_offset, __entry->target_fid, __entry->target_offset, __entry->len, __entry->rc) 249 + ) 250 + 251 + #define DEFINE_SMB3_COPY_RANGE_ERR_EVENT(name) \ 252 + DEFINE_EVENT(smb3_copy_range_err_class, smb3_##name, \ 253 + TP_PROTO(unsigned int xid, \ 254 + __u64 src_fid, \ 255 + __u64 target_fid, \ 256 + __u32 tid, \ 257 + __u64 sesid, \ 258 + __u64 src_offset, \ 259 + __u64 target_offset, \ 260 + __u32 len, \ 261 + int rc), \ 262 + TP_ARGS(xid, src_fid, target_fid, tid, sesid, src_offset, target_offset, len, rc)) 263 + 264 + DEFINE_SMB3_COPY_RANGE_ERR_EVENT(clone_err); 265 + /* TODO: Add SMB3_COPY_RANGE_ERR_EVENT(copychunk_err) */ 266 267 /* For logging successful read or write */ 268 DECLARE_EVENT_CLASS(smb3_rw_done_class,