提交 d84c198f 编写于 作者: M Matthew R. Ochs 提交者: Martin K. Petersen

scsi: cxlflash: Derive pid through accessors

The cxlflash driver tracks process IDs alongside contexts to validate
context ownership. Currently, the process IDs are derived by directly
accessing values from the 'current' task pointer. While this method of
access is fine for the current process, it is incorrect when the parent
process ID is needed as the access requires serialization.

To address the incorrect issue and provide a consistent means of
deriving the process ID within the cxlflash driver, use the task
accessors defined linux/sched.h.
Signed-off-by: NMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: NUma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 0d419130
...@@ -165,7 +165,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid, ...@@ -165,7 +165,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid,
struct llun_info *lli = arg; struct llun_info *lli = arg;
u64 ctxid = DECODE_CTXID(rctxid); u64 ctxid = DECODE_CTXID(rctxid);
int rc; int rc;
pid_t pid = current->tgid, ctxpid = 0; pid_t pid = task_tgid_nr(current), ctxpid = 0;
if (ctx_ctrl & CTX_CTRL_FILE) { if (ctx_ctrl & CTX_CTRL_FILE) {
lli = NULL; lli = NULL;
...@@ -173,7 +173,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid, ...@@ -173,7 +173,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid,
} }
if (ctx_ctrl & CTX_CTRL_CLONE) if (ctx_ctrl & CTX_CTRL_CLONE)
pid = current->parent->tgid; pid = task_ppid_nr(current);
if (likely(ctxid < MAX_CONTEXT)) { if (likely(ctxid < MAX_CONTEXT)) {
while (true) { while (true) {
...@@ -824,7 +824,7 @@ static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg, ...@@ -824,7 +824,7 @@ static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg,
ctxi->rht_perms = perms; ctxi->rht_perms = perms;
ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl; ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl;
ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid); ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
ctxi->pid = current->tgid; /* tgid = pid */ ctxi->pid = task_tgid_nr(current); /* tgid = pid */
ctxi->ctx = ctx; ctxi->ctx = ctx;
ctxi->cfg = cfg; ctxi->cfg = cfg;
ctxi->file = file; ctxi->file = file;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册