Page MenuHomeFreeBSD

D45245.diff
No OneTemporary

D45245.diff

diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -4010,8 +4010,23 @@
error = BUF_TIMELOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL, "getblku", 0,
0);
- if (error != 0)
+ if (error != 0) {
+ KASSERT(error == EBUSY,
+ ("getblk: unexpected error %d from buf try-lock", error));
+ /*
+ * We failed a buf try-lock.
+ *
+ * With GB_LOCK_NOWAIT, just return, rather than taking the
+ * bufobj interlock and trying again, since we would probably
+ * fail again anyway. This is okay even if the buf's identity
+ * changed and we contended on the wrong lock, as changing
+ * identity itself requires the buf lock, and we could have
+ * contended on the right lock.
+ */
+ if ((flags & GB_LOCK_NOWAIT) != 0)
+ return (error);
goto loop;
+ }
/* Verify buf identify has not changed since lookup. */
if (bp->b_bufobj == bo && bp->b_lblkno == blkno)
@@ -4020,6 +4035,10 @@
/* It changed, fallback to locked lookup. */
BUF_UNLOCK_RAW(bp);
+ /* As above, with GB_LOCK_NOWAIT, just return. */
+ if ((flags & GB_LOCK_NOWAIT) != 0)
+ return (EBUSY);
+
loop:
BO_RLOCK(bo);
bp = gbincore(bo, blkno);

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 12, 8:01 AM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15763702
Default Alt Text
D45245.diff (1 KB)

Event Timeline