Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107179448
D45245.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D45245.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D45245: getblk: fail faster with GB_LOCK_NOWAIT
Attached
Detach File
Event Timeline
Log In to Comment