aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fifo.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fifo.c')
-rw-r--r--fs/fifo.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/fs/fifo.c b/fs/fifo.c
index b16e2f597d61..2c27f56d7304 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -28,14 +28,14 @@ static void wait_for_partner(struct inode* inode, unsigned int *cnt)
28 28
29static void wake_up_partner(struct inode* inode) 29static void wake_up_partner(struct inode* inode)
30{ 30{
31 wake_up_interruptible(PIPE_WAIT(*inode)); 31 wake_up_interruptible(&inode->i_pipe->wait);
32} 32}
33 33
34static int fifo_open(struct inode *inode, struct file *filp) 34static int fifo_open(struct inode *inode, struct file *filp)
35{ 35{
36 int ret; 36 int ret;
37 37
38 mutex_lock(PIPE_MUTEX(*inode)); 38 mutex_lock(&inode->i_mutex);
39 if (!inode->i_pipe) { 39 if (!inode->i_pipe) {
40 ret = -ENOMEM; 40 ret = -ENOMEM;
41 inode->i_pipe = alloc_pipe_info(inode); 41 inode->i_pipe = alloc_pipe_info(inode);
@@ -55,18 +55,18 @@ static int fifo_open(struct inode *inode, struct file *filp)
55 * opened, even when there is no process writing the FIFO. 55 * opened, even when there is no process writing the FIFO.
56 */ 56 */
57 filp->f_op = &read_fifo_fops; 57 filp->f_op = &read_fifo_fops;
58 PIPE_RCOUNTER(*inode)++; 58 inode->i_pipe->r_counter++;
59 if (PIPE_READERS(*inode)++ == 0) 59 if (inode->i_pipe->readers++ == 0)
60 wake_up_partner(inode); 60 wake_up_partner(inode);
61 61
62 if (!PIPE_WRITERS(*inode)) { 62 if (!inode->i_pipe->writers) {
63 if ((filp->f_flags & O_NONBLOCK)) { 63 if ((filp->f_flags & O_NONBLOCK)) {
64 /* suppress POLLHUP until we have 64 /* suppress POLLHUP until we have
65 * seen a writer */ 65 * seen a writer */
66 filp->f_version = PIPE_WCOUNTER(*inode); 66 filp->f_version = inode->i_pipe->w_counter;
67 } else 67 } else
68 { 68 {
69 wait_for_partner(inode, &PIPE_WCOUNTER(*inode)); 69 wait_for_partner(inode, &inode->i_pipe->w_counter);
70 if(signal_pending(current)) 70 if(signal_pending(current))
71 goto err_rd; 71 goto err_rd;
72 } 72 }
@@ -80,16 +80,16 @@ static int fifo_open(struct inode *inode, struct file *filp)
80 * errno=ENXIO when there is no process reading the FIFO. 80 * errno=ENXIO when there is no process reading the FIFO.
81 */ 81 */
82 ret = -ENXIO; 82 ret = -ENXIO;
83 if ((filp->f_flags & O_NONBLOCK) && !PIPE_READERS(*inode)) 83 if ((filp->f_flags & O_NONBLOCK) && !inode->i_pipe->readers)
84 goto err; 84 goto err;
85 85
86 filp->f_op = &write_fifo_fops; 86 filp->f_op = &write_fifo_fops;
87 PIPE_WCOUNTER(*inode)++; 87 inode->i_pipe->w_counter++;
88 if (!PIPE_WRITERS(*inode)++) 88 if (!inode->i_pipe->writers++)
89 wake_up_partner(inode); 89 wake_up_partner(inode);
90 90
91 if (!PIPE_READERS(*inode)) { 91 if (!inode->i_pipe->readers) {
92 wait_for_partner(inode, &PIPE_RCOUNTER(*inode)); 92 wait_for_partner(inode, &inode->i_pipe->r_counter);
93 if (signal_pending(current)) 93 if (signal_pending(current))
94 goto err_wr; 94 goto err_wr;
95 } 95 }
@@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
104 */ 104 */
105 filp->f_op = &rdwr_fifo_fops; 105 filp->f_op = &rdwr_fifo_fops;
106 106
107 PIPE_READERS(*inode)++; 107 inode->i_pipe->readers++;
108 PIPE_WRITERS(*inode)++; 108 inode->i_pipe->writers++;
109 PIPE_RCOUNTER(*inode)++; 109 inode->i_pipe->r_counter++;
110 PIPE_WCOUNTER(*inode)++; 110 inode->i_pipe->w_counter++;
111 if (PIPE_READERS(*inode) == 1 || PIPE_WRITERS(*inode) == 1) 111 if (inode->i_pipe->readers == 1 || inode->i_pipe->writers == 1)
112 wake_up_partner(inode); 112 wake_up_partner(inode);
113 break; 113 break;
114 114
@@ -118,27 +118,27 @@ static int fifo_open(struct inode *inode, struct file *filp)
118 } 118 }
119 119
120 /* Ok! */ 120 /* Ok! */
121 mutex_unlock(PIPE_MUTEX(*inode)); 121 mutex_unlock(&inode->i_mutex);
122 return 0; 122 return 0;
123 123
124err_rd: 124err_rd:
125 if (!--PIPE_READERS(*inode)) 125 if (!--inode->i_pipe->readers)
126 wake_up_interruptible(PIPE_WAIT(*inode)); 126 wake_up_interruptible(&inode->i_pipe->wait);
127 ret = -ERESTARTSYS; 127 ret = -ERESTARTSYS;
128 goto err; 128 goto err;
129 129
130err_wr: 130err_wr:
131 if (!--PIPE_WRITERS(*inode)) 131 if (!--inode->i_pipe->writers)
132 wake_up_interruptible(PIPE_WAIT(*inode)); 132 wake_up_interruptible(&inode->i_pipe->wait);
133 ret = -ERESTARTSYS; 133 ret = -ERESTARTSYS;
134 goto err; 134 goto err;
135 135
136err: 136err:
137 if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) 137 if (!inode->i_pipe->readers && !inode->i_pipe->writers)
138 free_pipe_info(inode); 138 free_pipe_info(inode);
139 139
140err_nocleanup: 140err_nocleanup:
141 mutex_unlock(PIPE_MUTEX(*inode)); 141 mutex_unlock(&inode->i_mutex);
142 return ret; 142 return ret;
143} 143}
144 144