diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-05-13 14:45:32 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-05-13 14:45:32 -0400 |
commit | 40d97692fbfe52ef68fa771d8121394b2210fd67 (patch) | |
tree | a9caaf61f737308b1a34e1a07914ba45d02bb434 | |
parent | 74116f580b7279543340dd716a2af642f5c1c2c7 (diff) |
IB/ipath: Make ipath_portdata work with struct pid * not pid_t
The official reason is "with the presence of pid namespaces in the
kernel using pid_t-s inside one is no longer safe."
But the reason I fix this right now is the following:
About a month ago (when 2.6.25 was not yet released) there still was a
one last caller of a to-be-deprecated-soon function find_pid() - the
kill_proc() function, which in turn was only used by nfs callback
code.
During the last merge window, this last caller was finally eliminated
by some NFS patch(es) and I was about to finally kill this kill_proc()
and find_pid(), but found, that I was late and the kill_proc is now
called from the ipath driver since commit 58411d1c ("IB/ipath: Head of
Line blocking vs forward progress of user apps").
So here's a patch that fixes this code to use struct pid * and (!)
the kill_pid routine.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_driver.c | 18 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_file_ops.c | 19 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_kernel.h | 4 |
3 files changed, 23 insertions, 18 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index ce7b7c34360e..258e66cf3546 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c | |||
@@ -2616,7 +2616,7 @@ int ipath_reset_device(int unit) | |||
2616 | ipath_dbg("unit %u port %d is in use " | 2616 | ipath_dbg("unit %u port %d is in use " |
2617 | "(PID %u cmd %s), can't reset\n", | 2617 | "(PID %u cmd %s), can't reset\n", |
2618 | unit, i, | 2618 | unit, i, |
2619 | dd->ipath_pd[i]->port_pid, | 2619 | pid_nr(dd->ipath_pd[i]->port_pid), |
2620 | dd->ipath_pd[i]->port_comm); | 2620 | dd->ipath_pd[i]->port_comm); |
2621 | ret = -EBUSY; | 2621 | ret = -EBUSY; |
2622 | goto bail; | 2622 | goto bail; |
@@ -2654,19 +2654,21 @@ bail: | |||
2654 | static int ipath_signal_procs(struct ipath_devdata *dd, int sig) | 2654 | static int ipath_signal_procs(struct ipath_devdata *dd, int sig) |
2655 | { | 2655 | { |
2656 | int i, sub, any = 0; | 2656 | int i, sub, any = 0; |
2657 | pid_t pid; | 2657 | struct pid *pid; |
2658 | 2658 | ||
2659 | if (!dd->ipath_pd) | 2659 | if (!dd->ipath_pd) |
2660 | return 0; | 2660 | return 0; |
2661 | for (i = 1; i < dd->ipath_cfgports; i++) { | 2661 | for (i = 1; i < dd->ipath_cfgports; i++) { |
2662 | if (!dd->ipath_pd[i] || !dd->ipath_pd[i]->port_cnt || | 2662 | if (!dd->ipath_pd[i] || !dd->ipath_pd[i]->port_cnt) |
2663 | !dd->ipath_pd[i]->port_pid) | ||
2664 | continue; | 2663 | continue; |
2665 | pid = dd->ipath_pd[i]->port_pid; | 2664 | pid = dd->ipath_pd[i]->port_pid; |
2665 | if (!pid) | ||
2666 | continue; | ||
2667 | |||
2666 | dev_info(&dd->pcidev->dev, "context %d in use " | 2668 | dev_info(&dd->pcidev->dev, "context %d in use " |
2667 | "(PID %u), sending signal %d\n", | 2669 | "(PID %u), sending signal %d\n", |
2668 | i, pid, sig); | 2670 | i, pid_nr(pid), sig); |
2669 | kill_proc(pid, sig, 1); | 2671 | kill_pid(pid, sig, 1); |
2670 | any++; | 2672 | any++; |
2671 | for (sub = 0; sub < INFINIPATH_MAX_SUBPORT; sub++) { | 2673 | for (sub = 0; sub < INFINIPATH_MAX_SUBPORT; sub++) { |
2672 | pid = dd->ipath_pd[i]->port_subpid[sub]; | 2674 | pid = dd->ipath_pd[i]->port_subpid[sub]; |
@@ -2674,8 +2676,8 @@ static int ipath_signal_procs(struct ipath_devdata *dd, int sig) | |||
2674 | continue; | 2676 | continue; |
2675 | dev_info(&dd->pcidev->dev, "sub-context " | 2677 | dev_info(&dd->pcidev->dev, "sub-context " |
2676 | "%d:%d in use (PID %u), sending " | 2678 | "%d:%d in use (PID %u), sending " |
2677 | "signal %d\n", i, sub, pid, sig); | 2679 | "signal %d\n", i, sub, pid_nr(pid), sig); |
2678 | kill_proc(pid, sig, 1); | 2680 | kill_pid(pid, sig, 1); |
2679 | any++; | 2681 | any++; |
2680 | } | 2682 | } |
2681 | } | 2683 | } |
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index 3295177c937e..b472b15637f0 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -555,7 +555,7 @@ static int ipath_tid_free(struct ipath_portdata *pd, unsigned subport, | |||
555 | p = dd->ipath_pageshadow[porttid + tid]; | 555 | p = dd->ipath_pageshadow[porttid + tid]; |
556 | dd->ipath_pageshadow[porttid + tid] = NULL; | 556 | dd->ipath_pageshadow[porttid + tid] = NULL; |
557 | ipath_cdbg(VERBOSE, "PID %u freeing TID %u\n", | 557 | ipath_cdbg(VERBOSE, "PID %u freeing TID %u\n", |
558 | pd->port_pid, tid); | 558 | pid_nr(pd->port_pid), tid); |
559 | dd->ipath_f_put_tid(dd, &tidbase[tid], | 559 | dd->ipath_f_put_tid(dd, &tidbase[tid], |
560 | RCVHQ_RCV_TYPE_EXPECTED, | 560 | RCVHQ_RCV_TYPE_EXPECTED, |
561 | dd->ipath_tidinvalid); | 561 | dd->ipath_tidinvalid); |
@@ -1609,7 +1609,7 @@ static int try_alloc_port(struct ipath_devdata *dd, int port, | |||
1609 | port); | 1609 | port); |
1610 | pd->port_cnt = 1; | 1610 | pd->port_cnt = 1; |
1611 | port_fp(fp) = pd; | 1611 | port_fp(fp) = pd; |
1612 | pd->port_pid = current->pid; | 1612 | pd->port_pid = get_pid(task_pid(current)); |
1613 | strncpy(pd->port_comm, current->comm, sizeof(pd->port_comm)); | 1613 | strncpy(pd->port_comm, current->comm, sizeof(pd->port_comm)); |
1614 | ipath_stats.sps_ports++; | 1614 | ipath_stats.sps_ports++; |
1615 | ret = 0; | 1615 | ret = 0; |
@@ -1793,14 +1793,15 @@ static int find_shared_port(struct file *fp, | |||
1793 | } | 1793 | } |
1794 | port_fp(fp) = pd; | 1794 | port_fp(fp) = pd; |
1795 | subport_fp(fp) = pd->port_cnt++; | 1795 | subport_fp(fp) = pd->port_cnt++; |
1796 | pd->port_subpid[subport_fp(fp)] = current->pid; | 1796 | pd->port_subpid[subport_fp(fp)] = |
1797 | get_pid(task_pid(current)); | ||
1797 | tidcursor_fp(fp) = 0; | 1798 | tidcursor_fp(fp) = 0; |
1798 | pd->active_slaves |= 1 << subport_fp(fp); | 1799 | pd->active_slaves |= 1 << subport_fp(fp); |
1799 | ipath_cdbg(PROC, | 1800 | ipath_cdbg(PROC, |
1800 | "%s[%u] %u sharing %s[%u] unit:port %u:%u\n", | 1801 | "%s[%u] %u sharing %s[%u] unit:port %u:%u\n", |
1801 | current->comm, current->pid, | 1802 | current->comm, current->pid, |
1802 | subport_fp(fp), | 1803 | subport_fp(fp), |
1803 | pd->port_comm, pd->port_pid, | 1804 | pd->port_comm, pid_nr(pd->port_pid), |
1804 | dd->ipath_unit, pd->port_port); | 1805 | dd->ipath_unit, pd->port_port); |
1805 | ret = 1; | 1806 | ret = 1; |
1806 | goto done; | 1807 | goto done; |
@@ -2066,7 +2067,8 @@ static int ipath_close(struct inode *in, struct file *fp) | |||
2066 | * the slave(s) don't wait for receive data forever. | 2067 | * the slave(s) don't wait for receive data forever. |
2067 | */ | 2068 | */ |
2068 | pd->active_slaves &= ~(1 << fd->subport); | 2069 | pd->active_slaves &= ~(1 << fd->subport); |
2069 | pd->port_subpid[fd->subport] = 0; | 2070 | put_pid(pd->port_subpid[fd->subport]); |
2071 | pd->port_subpid[fd->subport] = NULL; | ||
2070 | mutex_unlock(&ipath_mutex); | 2072 | mutex_unlock(&ipath_mutex); |
2071 | goto bail; | 2073 | goto bail; |
2072 | } | 2074 | } |
@@ -2074,7 +2076,7 @@ static int ipath_close(struct inode *in, struct file *fp) | |||
2074 | 2076 | ||
2075 | if (pd->port_hdrqfull) { | 2077 | if (pd->port_hdrqfull) { |
2076 | ipath_cdbg(PROC, "%s[%u] had %u rcvhdrqfull errors " | 2078 | ipath_cdbg(PROC, "%s[%u] had %u rcvhdrqfull errors " |
2077 | "during run\n", pd->port_comm, pd->port_pid, | 2079 | "during run\n", pd->port_comm, pid_nr(pd->port_pid), |
2078 | pd->port_hdrqfull); | 2080 | pd->port_hdrqfull); |
2079 | pd->port_hdrqfull = 0; | 2081 | pd->port_hdrqfull = 0; |
2080 | } | 2082 | } |
@@ -2134,11 +2136,12 @@ static int ipath_close(struct inode *in, struct file *fp) | |||
2134 | unlock_expected_tids(pd); | 2136 | unlock_expected_tids(pd); |
2135 | ipath_stats.sps_ports--; | 2137 | ipath_stats.sps_ports--; |
2136 | ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n", | 2138 | ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n", |
2137 | pd->port_comm, pd->port_pid, | 2139 | pd->port_comm, pid_nr(pd->port_pid), |
2138 | dd->ipath_unit, port); | 2140 | dd->ipath_unit, port); |
2139 | } | 2141 | } |
2140 | 2142 | ||
2141 | pd->port_pid = 0; | 2143 | put_pid(pd->port_pid); |
2144 | pd->port_pid = NULL; | ||
2142 | dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */ | 2145 | dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */ |
2143 | mutex_unlock(&ipath_mutex); | 2146 | mutex_unlock(&ipath_mutex); |
2144 | ipath_free_pddata(dd, pd); /* after releasing the mutex */ | 2147 | ipath_free_pddata(dd, pd); /* after releasing the mutex */ |
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h index 02b24a340599..20975875a8d1 100644 --- a/drivers/infiniband/hw/ipath/ipath_kernel.h +++ b/drivers/infiniband/hw/ipath/ipath_kernel.h | |||
@@ -159,8 +159,8 @@ struct ipath_portdata { | |||
159 | /* saved total number of polled urgent packets for poll edge trigger */ | 159 | /* saved total number of polled urgent packets for poll edge trigger */ |
160 | u32 port_urgent_poll; | 160 | u32 port_urgent_poll; |
161 | /* pid of process using this port */ | 161 | /* pid of process using this port */ |
162 | pid_t port_pid; | 162 | struct pid *port_pid; |
163 | pid_t port_subpid[INFINIPATH_MAX_SUBPORT]; | 163 | struct pid *port_subpid[INFINIPATH_MAX_SUBPORT]; |
164 | /* same size as task_struct .comm[] */ | 164 | /* same size as task_struct .comm[] */ |
165 | char port_comm[16]; | 165 | char port_comm[16]; |
166 | /* pkeys set by this use of this port */ | 166 | /* pkeys set by this use of this port */ |