@@ -133,47 +133,70 @@ nfs_async_iocounter_wait(struct rpc_task *task, struct nfs_lock_context *l_ctx)
133
133
EXPORT_SYMBOL_GPL (nfs_async_iocounter_wait );
134
134
135
135
/*
136
- * nfs_page_group_lock - lock the head of the page group
137
- * @req - request in group that is to be locked
136
+ * nfs_page_set_headlock - set the request PG_HEADLOCK
137
+ * @req: request that is to be locked
138
138
*
139
- * this lock must be held when traversing or modifying the page
140
- * group list
139
+ * this lock must be held when modifying req->wb_head
141
140
*
142
141
* return 0 on success, < 0 on error
143
142
*/
144
143
int
145
- nfs_page_group_lock (struct nfs_page * req )
144
+ nfs_page_set_headlock (struct nfs_page * req )
146
145
{
147
- struct nfs_page * head = req -> wb_head ;
148
-
149
- WARN_ON_ONCE (head != head -> wb_head );
150
-
151
- if (!test_and_set_bit (PG_HEADLOCK , & head -> wb_flags ))
146
+ if (!test_and_set_bit (PG_HEADLOCK , & req -> wb_flags ))
152
147
return 0 ;
153
148
154
- set_bit (PG_CONTENDED1 , & head -> wb_flags );
149
+ set_bit (PG_CONTENDED1 , & req -> wb_flags );
155
150
smp_mb__after_atomic ();
156
- return wait_on_bit_lock (& head -> wb_flags , PG_HEADLOCK ,
151
+ return wait_on_bit_lock (& req -> wb_flags , PG_HEADLOCK ,
157
152
TASK_UNINTERRUPTIBLE );
158
153
}
159
154
160
155
/*
161
- * nfs_page_group_unlock - unlock the head of the page group
162
- * @req - request in group that is to be unlocked
156
+ * nfs_page_clear_headlock - clear the request PG_HEADLOCK
157
+ * @req: request that is to be locked
163
158
*/
164
159
void
165
- nfs_page_group_unlock (struct nfs_page * req )
160
+ nfs_page_clear_headlock (struct nfs_page * req )
166
161
{
167
- struct nfs_page * head = req -> wb_head ;
168
-
169
- WARN_ON_ONCE (head != head -> wb_head );
170
-
171
162
smp_mb__before_atomic ();
172
- clear_bit (PG_HEADLOCK , & head -> wb_flags );
163
+ clear_bit (PG_HEADLOCK , & req -> wb_flags );
173
164
smp_mb__after_atomic ();
174
- if (!test_bit (PG_CONTENDED1 , & head -> wb_flags ))
165
+ if (!test_bit (PG_CONTENDED1 , & req -> wb_flags ))
175
166
return ;
176
- wake_up_bit (& head -> wb_flags , PG_HEADLOCK );
167
+ wake_up_bit (& req -> wb_flags , PG_HEADLOCK );
168
+ }
169
+
170
+ /*
171
+ * nfs_page_group_lock - lock the head of the page group
172
+ * @req: request in group that is to be locked
173
+ *
174
+ * this lock must be held when traversing or modifying the page
175
+ * group list
176
+ *
177
+ * return 0 on success, < 0 on error
178
+ */
179
+ int
180
+ nfs_page_group_lock (struct nfs_page * req )
181
+ {
182
+ int ret ;
183
+
184
+ ret = nfs_page_set_headlock (req );
185
+ if (ret || req -> wb_head == req )
186
+ return ret ;
187
+ return nfs_page_set_headlock (req -> wb_head );
188
+ }
189
+
190
+ /*
191
+ * nfs_page_group_unlock - unlock the head of the page group
192
+ * @req: request in group that is to be unlocked
193
+ */
194
+ void
195
+ nfs_page_group_unlock (struct nfs_page * req )
196
+ {
197
+ if (req != req -> wb_head )
198
+ nfs_page_clear_headlock (req -> wb_head );
199
+ nfs_page_clear_headlock (req );
177
200
}
178
201
179
202
/*
0 commit comments