Skip to content

Commit

Permalink
(client) fixed race condition between client and kernel in retrieving…
Browse files Browse the repository at this point in the history
… open file list (FreeBSD only)
  • Loading branch information
acid-maker committed Sep 14, 2022
1 parent cae79a8 commit 023198e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This file lists noteworthy changes in MooseFS.
- (all) using SIGUSR1 instead of SIGINFO even on system where SIGINFO is defined
- (master) changed default ATIME_MODE to 2 (issue #478)
- (master) fixed atime/mtime/ctime preservation during snapshot (in HA environement upgrade may cause one time desync ; issue #489)
- (client) fixed race condition between client and kernel in retrieving open file list (FreeBSD only)

* MooseFS 3.0.116-1 (2021-08-10)

Expand Down
28 changes: 15 additions & 13 deletions mfsclient/sustained_inodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ void sinodes_pid_inodes(pid_t pid) {
#elif defined(__FreeBSD__)
struct kinfo_file *kif;
uint8_t *p;
size_t len, olen;
size_t len;
int i;
int name[4];
int error;

Expand All @@ -211,27 +212,28 @@ void sinodes_pid_inodes(pid_t pid) {
name[2] = KERN_PROC_FILEDESC;
name[3] = pid;
p = NULL;
if (sysctl(name, 4, NULL, &len, NULL, 0)<0) {
if (errno!=ESRCH && errno!=EBUSY) {
mfs_errlog(LOG_NOTICE,"sysctl(kern.proc.filedesc) error");
}
return;
}
if (len==0) {
return;
}
i = 0;
do {
len += len / 10;
if (sysctl(name, 4, NULL, &len, NULL, 0)<0) {
if (errno!=ESRCH && errno!=EBUSY) {
mfs_errlog(LOG_NOTICE,"sysctl(kern.proc.filedesc) error");
}
return;
}
if (len==0) {
return;
}
len += len / 2;
if (p!=NULL) {
free(p);
}
p = malloc(len);
if (p == NULL) {
return;
}
olen = len;
error = sysctl(name, 4, p, &len, NULL, 0);
} while (error < 0 && errno == ENOMEM && olen == len);
i++;
} while (error < 0 && errno == ENOMEM && i < 10);
if (error<0) {
if (errno!=ESRCH && errno!=EBUSY) {
mfs_errlog(LOG_NOTICE,"sysctl(kern.proc.filedesc) error");
Expand Down

0 comments on commit 023198e

Please sign in to comment.