fs/smb/server/ksmbd_work.c
Source file repositories/reference/linux-study-clean/fs/smb/server/ksmbd_work.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/ksmbd_work.c- Extension
.c- Size
- 3974 bytes
- Lines
- 176
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hlinux/mm.hlinux/slab.hlinux/workqueue.hserver.hconnection.hksmbd_work.hmgmt/ksmbd_ida.h
Detected Declarations
function ksmbd_free_work_structfunction list_for_each_entry_safefunction ksmbd_work_pool_destroyfunction ksmbd_work_pool_initfunction ksmbd_workqueue_initfunction ksmbd_workqueue_destroyfunction ksmbd_queue_workfunction __ksmbd_iov_pinfunction __ksmbd_iov_pin_rspfunction ksmbd_iov_pin_rspfunction ksmbd_iov_pin_rsp_readfunction allocate_interim_rsp_buf
Annotated Snippet
if (!work->iov) {
kmem_cache_free(work_cache, work);
work = NULL;
}
}
return work;
}
void ksmbd_free_work_struct(struct ksmbd_work *work)
{
struct aux_read *ar, *tmp;
WARN_ON(work->saved_cred != NULL);
kvfree(work->response_buf);
list_for_each_entry_safe(ar, tmp, &work->aux_read_list, entry) {
kvfree(ar->buf);
list_del(&ar->entry);
kfree(ar);
}
kfree(work->tr_buf);
kvfree(work->compress_buf);
kvfree(work->request_buf);
kfree(work->iov);
if (work->async_id)
ksmbd_release_id(&work->conn->async_ida, work->async_id);
kmem_cache_free(work_cache, work);
}
void ksmbd_work_pool_destroy(void)
{
kmem_cache_destroy(work_cache);
}
int ksmbd_work_pool_init(void)
{
work_cache = kmem_cache_create("ksmbd_work_cache",
sizeof(struct ksmbd_work), 0,
SLAB_HWCACHE_ALIGN, NULL);
if (!work_cache)
return -ENOMEM;
return 0;
}
int ksmbd_workqueue_init(void)
{
ksmbd_wq = alloc_workqueue("ksmbd-io", WQ_PERCPU, 0);
if (!ksmbd_wq)
return -ENOMEM;
return 0;
}
void ksmbd_workqueue_destroy(void)
{
destroy_workqueue(ksmbd_wq);
ksmbd_wq = NULL;
}
bool ksmbd_queue_work(struct ksmbd_work *work)
{
return queue_work(ksmbd_wq, &work->work);
}
static inline void __ksmbd_iov_pin(struct ksmbd_work *work, void *ib,
unsigned int ib_len)
{
work->iov[++work->iov_idx].iov_base = ib;
work->iov[work->iov_idx].iov_len = ib_len;
work->iov_cnt++;
}
static int __ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len,
void *aux_buf, unsigned int aux_size)
{
struct aux_read *ar = NULL;
int need_iov_cnt = 1;
if (aux_size) {
need_iov_cnt++;
ar = kmalloc_obj(struct aux_read, KSMBD_DEFAULT_GFP);
if (!ar)
return -ENOMEM;
}
if (work->iov_alloc_cnt < work->iov_cnt + need_iov_cnt) {
struct kvec *new;
Annotation
- Immediate include surface: `linux/list.h`, `linux/mm.h`, `linux/slab.h`, `linux/workqueue.h`, `server.h`, `connection.h`, `ksmbd_work.h`, `mgmt/ksmbd_ida.h`.
- Detected declarations: `function ksmbd_free_work_struct`, `function list_for_each_entry_safe`, `function ksmbd_work_pool_destroy`, `function ksmbd_work_pool_init`, `function ksmbd_workqueue_init`, `function ksmbd_workqueue_destroy`, `function ksmbd_queue_work`, `function __ksmbd_iov_pin`, `function __ksmbd_iov_pin_rsp`, `function ksmbd_iov_pin_rsp`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.