* [bug report] f2fs: fix missing unlock(sbi->gc_mutex)
@ 2019-01-03 10:54 Dan Carpenter
2019-01-04 2:30 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-01-03 10:54 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel
Hello Jaegeuk Kim,
The patch 8f31b4665c14: "f2fs: fix missing unlock(sbi->gc_mutex)"
from Dec 17, 2018, leads to the following static checker warning:
fs/f2fs/super.c:1481 f2fs_disable_checkpoint()
error: double lock 'mutex:&sbi->gc_mutex'
fs/f2fs/super.c
1456 static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
1457 {
1458 struct cp_control cpc;
1459 int err;
1460
1461 sbi->sb->s_flags |= SB_ACTIVE;
1462
1463 f2fs_update_time(sbi, DISABLE_TIME);
1464
1465 while (!f2fs_time_over(sbi, DISABLE_TIME)) {
1466 mutex_lock(&sbi->gc_mutex);
^^^^^^^^^^^^^^^^^^^^^^^^^^
Lock.
1467 err = f2fs_gc(sbi, true, false, NULL_SEGNO);
1468 if (err == -ENODATA)
1469 break;
1470 if (err && err != -EAGAIN)
1471 return err;
1472 }
1473
1474 err = sync_filesystem(sbi->sb);
1475 if (err)
1476 return err;
1477
1478 if (f2fs_disable_cp_again(sbi))
1479 return -EAGAIN;
1480
--> 1481 mutex_lock(&sbi->gc_mutex);
^^^^^^^^^^^^^
Deadlock?
1482 cpc.reason = CP_PAUSE;
1483 set_sbi_flag(sbi, SBI_CP_DISABLED);
1484 f2fs_write_checkpoint(sbi, &cpc);
1485
1486 sbi->unusable_block_count = 0;
1487 mutex_unlock(&sbi->gc_mutex);
1488 return 0;
1489 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] f2fs: fix missing unlock(sbi->gc_mutex)
2019-01-03 10:54 [bug report] f2fs: fix missing unlock(sbi->gc_mutex) Dan Carpenter
@ 2019-01-04 2:30 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2019-01-04 2:30 UTC (permalink / raw)
To: Dan Carpenter, jaegeuk; +Cc: linux-f2fs-devel
Hi Dan,
Thanks for the report.
The code logic here is okay, since unlock will be called inside f2fs_gc()
anyway. :)
FYI, the same report in below link from Julia, I've replied once. :)
https://lists.01.org/pipermail/kbuild-all/2018-December/056436.html
Thanks,
On 2019/1/3 18:54, Dan Carpenter wrote:
> Hello Jaegeuk Kim,
>
> The patch 8f31b4665c14: "f2fs: fix missing unlock(sbi->gc_mutex)"
> from Dec 17, 2018, leads to the following static checker warning:
>
> fs/f2fs/super.c:1481 f2fs_disable_checkpoint()
> error: double lock 'mutex:&sbi->gc_mutex'
>
> fs/f2fs/super.c
> 1456 static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
> 1457 {
> 1458 struct cp_control cpc;
> 1459 int err;
> 1460
> 1461 sbi->sb->s_flags |= SB_ACTIVE;
> 1462
> 1463 f2fs_update_time(sbi, DISABLE_TIME);
> 1464
> 1465 while (!f2fs_time_over(sbi, DISABLE_TIME)) {
> 1466 mutex_lock(&sbi->gc_mutex);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
> Lock.
>
> 1467 err = f2fs_gc(sbi, true, false, NULL_SEGNO);
> 1468 if (err == -ENODATA)
> 1469 break;
> 1470 if (err && err != -EAGAIN)
> 1471 return err;
> 1472 }
> 1473
> 1474 err = sync_filesystem(sbi->sb);
> 1475 if (err)
> 1476 return err;
> 1477
> 1478 if (f2fs_disable_cp_again(sbi))
> 1479 return -EAGAIN;
> 1480
> --> 1481 mutex_lock(&sbi->gc_mutex);
> ^^^^^^^^^^^^^
> Deadlock?
>
> 1482 cpc.reason = CP_PAUSE;
> 1483 set_sbi_flag(sbi, SBI_CP_DISABLED);
> 1484 f2fs_write_checkpoint(sbi, &cpc);
> 1485
> 1486 sbi->unusable_block_count = 0;
> 1487 mutex_unlock(&sbi->gc_mutex);
> 1488 return 0;
> 1489 }
>
> regards,
> dan carpenter
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-04 2:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-03 10:54 [bug report] f2fs: fix missing unlock(sbi->gc_mutex) Dan Carpenter
2019-01-04 2:30 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).