Skip to content

Commit e6fa4c7

Browse files
amir73ilbrauner
authored andcommitted
cachefiles: use kiocb_{start,end}_write() helpers
Use helpers instead of the open coded dance to silence lockdep warnings. Suggested-by: Jan Kara <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 8f73712 commit e6fa4c7

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

fs/cachefiles/io.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,7 @@ static void cachefiles_write_complete(struct kiocb *iocb, long ret)
259259

260260
_enter("%ld", ret);
261261

262-
/* Tell lockdep we inherited freeze protection from submission thread */
263-
__sb_writers_acquired(inode->i_sb, SB_FREEZE_WRITE);
264-
__sb_end_write(inode->i_sb, SB_FREEZE_WRITE);
262+
kiocb_end_write(iocb);
265263

266264
if (ret < 0)
267265
trace_cachefiles_io_error(object, inode, ret,
@@ -286,7 +284,6 @@ int __cachefiles_write(struct cachefiles_object *object,
286284
{
287285
struct cachefiles_cache *cache;
288286
struct cachefiles_kiocb *ki;
289-
struct inode *inode;
290287
unsigned int old_nofs;
291288
ssize_t ret;
292289
size_t len = iov_iter_count(iter);
@@ -322,19 +319,12 @@ int __cachefiles_write(struct cachefiles_object *object,
322319
ki->iocb.ki_complete = cachefiles_write_complete;
323320
atomic_long_add(ki->b_writing, &cache->b_writing);
324321

325-
/* Open-code file_start_write here to grab freeze protection, which
326-
* will be released by another thread in aio_complete_rw(). Fool
327-
* lockdep by telling it the lock got released so that it doesn't
328-
* complain about the held lock when we return to userspace.
329-
*/
330-
inode = file_inode(file);
331-
__sb_start_write(inode->i_sb, SB_FREEZE_WRITE);
332-
__sb_writers_release(inode->i_sb, SB_FREEZE_WRITE);
322+
kiocb_start_write(&ki->iocb);
333323

334324
get_file(ki->iocb.ki_filp);
335325
cachefiles_grab_object(object, cachefiles_obj_get_ioreq);
336326

337-
trace_cachefiles_write(object, inode, ki->iocb.ki_pos, len);
327+
trace_cachefiles_write(object, file_inode(file), ki->iocb.ki_pos, len);
338328
old_nofs = memalloc_nofs_save();
339329
ret = cachefiles_inject_write_error();
340330
if (ret == 0)

0 commit comments

Comments
 (0)