Loading fs/ksmbd/connection.c +1 −1 Original line number Diff line number Diff line Loading @@ -372,7 +372,7 @@ int ksmbd_conn_transport_init(void) ret = ksmbd_rdma_init(); if (ret) { pr_err("Failed to init KSMBD subsystem: %d\n", ret); pr_err("Failed to init RDMA subsystem: %d\n", ret); goto out; } out: Loading fs/ksmbd/oplock.c +2 −1 Original line number Diff line number Diff line Loading @@ -1447,6 +1447,7 @@ struct lease_ctx_info *parse_lease_state(void *open_req) * @tag: context name to search for * * Return: pointer to requested context, NULL if @str context not found * or error pointer if name length is invalid. */ struct create_context *smb2_find_context_vals(void *open_req, const char *tag) { Loading fs/ksmbd/smb2pdu.c +35 −58 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include "asn1.h" #include "connection.h" #include "transport_ipc.h" #include "transport_rdma.h" #include "vfs.h" #include "vfs_cache.h" #include "misc.h" Loading Loading @@ -2126,21 +2127,6 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, struct path *path) return rc; } static inline int check_context_err(void *ctx, char *str) { int err; err = PTR_ERR(ctx); ksmbd_debug(SMB, "find context %s err %d\n", str, err ? err : -ENOENT); if (err == -EINVAL) { pr_err("bad name length\n"); return err; } return 0; } static noinline int smb2_set_stream_name_xattr(struct path *path, struct ksmbd_file *fp, char *stream_name, int s_type) Loading Loading @@ -2523,11 +2509,10 @@ int smb2_open(struct ksmbd_work *work) if (req->CreateContextsOffset) { /* Parse non-durable handle create contexts */ context = smb2_find_context_vals(req, SMB2_CREATE_EA_BUFFER); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_EA_BUFFER); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { ea_buf = (struct create_ea_buf_req *)context; if (req->CreateOptions & FILE_NO_EA_KNOWLEDGE_LE) { rsp->hdr.Status = STATUS_ACCESS_DENIED; Loading @@ -2538,12 +2523,10 @@ int smb2_open(struct ksmbd_work *work) context = smb2_find_context_vals(req, SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { ksmbd_debug(SMB, "get query maximal access context\n"); maximal_access_ctxt = 1; Loading @@ -2551,12 +2534,10 @@ int smb2_open(struct ksmbd_work *work) context = smb2_find_context_vals(req, SMB2_CREATE_TIMEWARP_REQUEST); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_TIMEWARP_REQUEST); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { ksmbd_debug(SMB, "get timewarp context\n"); rc = -EBADF; goto err_out1; Loading @@ -2565,12 +2546,10 @@ int smb2_open(struct ksmbd_work *work) if (tcon->posix_extensions) { context = smb2_find_context_vals(req, SMB2_CREATE_TAG_POSIX); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_TAG_POSIX); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { struct create_posix *posix = (struct create_posix *)context; ksmbd_debug(SMB, "get posix context\n"); Loading Loading @@ -2968,12 +2947,10 @@ int smb2_open(struct ksmbd_work *work) az_req = (struct create_alloc_size_req *)smb2_find_context_vals(req, SMB2_CREATE_ALLOCATION_SIZE); if (IS_ERR_OR_NULL(az_req)) { rc = check_context_err(az_req, SMB2_CREATE_ALLOCATION_SIZE); if (rc < 0) if (IS_ERR(az_req)) { rc = PTR_ERR(az_req); goto err_out; } else { } else if (az_req) { loff_t alloc_size = le64_to_cpu(az_req->AllocationSize); int err; Loading @@ -2990,11 +2967,10 @@ int smb2_open(struct ksmbd_work *work) } context = smb2_find_context_vals(req, SMB2_CREATE_QUERY_ON_DISK_ID); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_QUERY_ON_DISK_ID); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out; } else { } else if (context) { ksmbd_debug(SMB, "get query on disk id context\n"); query_disk_id = 1; } Loading Loading @@ -6860,7 +6836,7 @@ int smb2_lock(struct ksmbd_work *work) rsp->Reserved = 0; inc_rfc1001_len(rsp, 4); ksmbd_fd_put(work, fp); return err; return 0; out: list_for_each_entry_safe(smb_lock, tmp, &lock_list, llist) { Loading @@ -6871,15 +6847,16 @@ int smb2_lock(struct ksmbd_work *work) list_for_each_entry_safe(smb_lock, tmp, &rollback_list, llist) { struct file_lock *rlock = NULL; int rc; rlock = smb_flock_init(filp); rlock->fl_type = F_UNLCK; rlock->fl_start = smb_lock->start; rlock->fl_end = smb_lock->end; err = vfs_lock_file(filp, 0, rlock, NULL); if (err) pr_err("rollback unlock fail : %d\n", err); rc = vfs_lock_file(filp, 0, rlock, NULL); if (rc) pr_err("rollback unlock fail : %d\n", rc); list_del(&smb_lock->llist); spin_lock(&work->conn->llist_lock); Loading @@ -6896,7 +6873,7 @@ int smb2_lock(struct ksmbd_work *work) ksmbd_debug(SMB, "failed in taking lock(flags : %x)\n", flags); smb2_set_err_rsp(work); ksmbd_fd_put(work, fp); return 0; return err; } static int fsctl_copychunk(struct ksmbd_work *work, struct smb2_ioctl_req *req, Loading Loading @@ -7052,11 +7029,11 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, &rsp->Buffer[nbytes]; nii_rsp->IfIndex = cpu_to_le32(netdev->ifindex); /* TODO: specify the RDMA capabilities */ if (netdev->num_tx_queues > 1) nii_rsp->Capability = cpu_to_le32(RSS_CAPABLE); else nii_rsp->Capability = 0; if (netdev->num_tx_queues > 1) nii_rsp->Capability |= cpu_to_le32(RSS_CAPABLE); if (ksmbd_rdma_capable_netdev(netdev)) nii_rsp->Capability |= cpu_to_le32(RDMA_CAPABLE); nii_rsp->Next = cpu_to_le32(152); nii_rsp->Reserved = 0; Loading fs/ksmbd/transport_rdma.c +14 −0 Original line number Diff line number Diff line Loading @@ -2033,6 +2033,20 @@ int ksmbd_rdma_destroy(void) return 0; } bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { struct ib_device *ibdev; bool rdma_capable = false; ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_UNKNOWN); if (ibdev) { if (rdma_frwr_is_supported(&ibdev->attrs)) rdma_capable = true; ib_device_put(ibdev); } return rdma_capable; } static struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = { .prepare = smb_direct_prepare, .disconnect = smb_direct_disconnect, Loading fs/ksmbd/transport_rdma.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,9 +53,11 @@ struct smb_direct_data_transfer { #ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init(void); int ksmbd_rdma_destroy(void); bool ksmbd_rdma_capable_netdev(struct net_device *netdev); #else static inline int ksmbd_rdma_init(void) { return 0; } static inline int ksmbd_rdma_destroy(void) { return 0; } static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; } #endif #endif /* __KSMBD_TRANSPORT_RDMA_H__ */ Loading
fs/ksmbd/connection.c +1 −1 Original line number Diff line number Diff line Loading @@ -372,7 +372,7 @@ int ksmbd_conn_transport_init(void) ret = ksmbd_rdma_init(); if (ret) { pr_err("Failed to init KSMBD subsystem: %d\n", ret); pr_err("Failed to init RDMA subsystem: %d\n", ret); goto out; } out: Loading
fs/ksmbd/oplock.c +2 −1 Original line number Diff line number Diff line Loading @@ -1447,6 +1447,7 @@ struct lease_ctx_info *parse_lease_state(void *open_req) * @tag: context name to search for * * Return: pointer to requested context, NULL if @str context not found * or error pointer if name length is invalid. */ struct create_context *smb2_find_context_vals(void *open_req, const char *tag) { Loading
fs/ksmbd/smb2pdu.c +35 −58 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include "asn1.h" #include "connection.h" #include "transport_ipc.h" #include "transport_rdma.h" #include "vfs.h" #include "vfs_cache.h" #include "misc.h" Loading Loading @@ -2126,21 +2127,6 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, struct path *path) return rc; } static inline int check_context_err(void *ctx, char *str) { int err; err = PTR_ERR(ctx); ksmbd_debug(SMB, "find context %s err %d\n", str, err ? err : -ENOENT); if (err == -EINVAL) { pr_err("bad name length\n"); return err; } return 0; } static noinline int smb2_set_stream_name_xattr(struct path *path, struct ksmbd_file *fp, char *stream_name, int s_type) Loading Loading @@ -2523,11 +2509,10 @@ int smb2_open(struct ksmbd_work *work) if (req->CreateContextsOffset) { /* Parse non-durable handle create contexts */ context = smb2_find_context_vals(req, SMB2_CREATE_EA_BUFFER); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_EA_BUFFER); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { ea_buf = (struct create_ea_buf_req *)context; if (req->CreateOptions & FILE_NO_EA_KNOWLEDGE_LE) { rsp->hdr.Status = STATUS_ACCESS_DENIED; Loading @@ -2538,12 +2523,10 @@ int smb2_open(struct ksmbd_work *work) context = smb2_find_context_vals(req, SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { ksmbd_debug(SMB, "get query maximal access context\n"); maximal_access_ctxt = 1; Loading @@ -2551,12 +2534,10 @@ int smb2_open(struct ksmbd_work *work) context = smb2_find_context_vals(req, SMB2_CREATE_TIMEWARP_REQUEST); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_TIMEWARP_REQUEST); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { ksmbd_debug(SMB, "get timewarp context\n"); rc = -EBADF; goto err_out1; Loading @@ -2565,12 +2546,10 @@ int smb2_open(struct ksmbd_work *work) if (tcon->posix_extensions) { context = smb2_find_context_vals(req, SMB2_CREATE_TAG_POSIX); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_TAG_POSIX); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out1; } else { } else if (context) { struct create_posix *posix = (struct create_posix *)context; ksmbd_debug(SMB, "get posix context\n"); Loading Loading @@ -2968,12 +2947,10 @@ int smb2_open(struct ksmbd_work *work) az_req = (struct create_alloc_size_req *)smb2_find_context_vals(req, SMB2_CREATE_ALLOCATION_SIZE); if (IS_ERR_OR_NULL(az_req)) { rc = check_context_err(az_req, SMB2_CREATE_ALLOCATION_SIZE); if (rc < 0) if (IS_ERR(az_req)) { rc = PTR_ERR(az_req); goto err_out; } else { } else if (az_req) { loff_t alloc_size = le64_to_cpu(az_req->AllocationSize); int err; Loading @@ -2990,11 +2967,10 @@ int smb2_open(struct ksmbd_work *work) } context = smb2_find_context_vals(req, SMB2_CREATE_QUERY_ON_DISK_ID); if (IS_ERR_OR_NULL(context)) { rc = check_context_err(context, SMB2_CREATE_QUERY_ON_DISK_ID); if (rc < 0) if (IS_ERR(context)) { rc = PTR_ERR(context); goto err_out; } else { } else if (context) { ksmbd_debug(SMB, "get query on disk id context\n"); query_disk_id = 1; } Loading Loading @@ -6860,7 +6836,7 @@ int smb2_lock(struct ksmbd_work *work) rsp->Reserved = 0; inc_rfc1001_len(rsp, 4); ksmbd_fd_put(work, fp); return err; return 0; out: list_for_each_entry_safe(smb_lock, tmp, &lock_list, llist) { Loading @@ -6871,15 +6847,16 @@ int smb2_lock(struct ksmbd_work *work) list_for_each_entry_safe(smb_lock, tmp, &rollback_list, llist) { struct file_lock *rlock = NULL; int rc; rlock = smb_flock_init(filp); rlock->fl_type = F_UNLCK; rlock->fl_start = smb_lock->start; rlock->fl_end = smb_lock->end; err = vfs_lock_file(filp, 0, rlock, NULL); if (err) pr_err("rollback unlock fail : %d\n", err); rc = vfs_lock_file(filp, 0, rlock, NULL); if (rc) pr_err("rollback unlock fail : %d\n", rc); list_del(&smb_lock->llist); spin_lock(&work->conn->llist_lock); Loading @@ -6896,7 +6873,7 @@ int smb2_lock(struct ksmbd_work *work) ksmbd_debug(SMB, "failed in taking lock(flags : %x)\n", flags); smb2_set_err_rsp(work); ksmbd_fd_put(work, fp); return 0; return err; } static int fsctl_copychunk(struct ksmbd_work *work, struct smb2_ioctl_req *req, Loading Loading @@ -7052,11 +7029,11 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, &rsp->Buffer[nbytes]; nii_rsp->IfIndex = cpu_to_le32(netdev->ifindex); /* TODO: specify the RDMA capabilities */ if (netdev->num_tx_queues > 1) nii_rsp->Capability = cpu_to_le32(RSS_CAPABLE); else nii_rsp->Capability = 0; if (netdev->num_tx_queues > 1) nii_rsp->Capability |= cpu_to_le32(RSS_CAPABLE); if (ksmbd_rdma_capable_netdev(netdev)) nii_rsp->Capability |= cpu_to_le32(RDMA_CAPABLE); nii_rsp->Next = cpu_to_le32(152); nii_rsp->Reserved = 0; Loading
fs/ksmbd/transport_rdma.c +14 −0 Original line number Diff line number Diff line Loading @@ -2033,6 +2033,20 @@ int ksmbd_rdma_destroy(void) return 0; } bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { struct ib_device *ibdev; bool rdma_capable = false; ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_UNKNOWN); if (ibdev) { if (rdma_frwr_is_supported(&ibdev->attrs)) rdma_capable = true; ib_device_put(ibdev); } return rdma_capable; } static struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = { .prepare = smb_direct_prepare, .disconnect = smb_direct_disconnect, Loading
fs/ksmbd/transport_rdma.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,9 +53,11 @@ struct smb_direct_data_transfer { #ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init(void); int ksmbd_rdma_destroy(void); bool ksmbd_rdma_capable_netdev(struct net_device *netdev); #else static inline int ksmbd_rdma_init(void) { return 0; } static inline int ksmbd_rdma_destroy(void) { return 0; } static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; } #endif #endif /* __KSMBD_TRANSPORT_RDMA_H__ */