There was a race condition (hence OSD crash) between lfn_unlink
and lfn_open. The reason was FDCache lookup was called without
taking index lock from lfn_open. Lookup will increase reference
count and thus Clear will not be able to delete those FDs. FDs
will be leaked. The assert within FDCache clear was hitting
because of this.
Fixes: #9480
Signed-off-by: Somnath Roy <somnath.roy@sandisk.com>
oid.generation == ghobject_t::NO_GEN ));
assert(outfd);
int r = 0;
-
bool need_lock = true;
- if (!replaying) {
- *outfd = fdcache.lookup(oid);
- if (*outfd) {
- if (!index) {
- return 0;
- } else {
- if (!((*index).index)) {
- r = get_index(cid, index);
- return r;
- }
- }
- }
- }
-
int flags = O_RDWR;
+
if (create)
flags |= O_CREAT;
if (!index) {
index = &index2;
}
-
if (!((*index).index)) {
r = get_index(cid, index);
} else {
if (need_lock) {
((*index).index)->access_lock.get_write();
}
+ if (!replaying) {
+ *outfd = fdcache.lookup(oid);
+ if (*outfd) {
+ if (need_lock) {
+ ((*index).index)->access_lock.put_write();
+ }
+ return 0;
+ }
+ }
+
IndexedPath path2;
IndexedPath *path = &path2;