A folder whose `statfs()` is pending blocks opening its sibling folders and its parent

Abierto
#3,887 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, linux
Área
desktop

Línea de trabajo

Start with filesystem_info_start() and start_or_stop_io() in libnemo-private/nemo-directory-async.c to see how the per-directory statfs query and the low-priority queue serialize siblings. Then read load_directory() in src/nemo-view.c where NEMO_FILE_ATTRIBUTE_FILESYSTEM_INFO is awaited for the folder and its loaded subfolders. Reproduce with the provided FUSE helper and confirm that only the slow folder waits while its sibling and parent open; no test file is named in the payload.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Distribution

Linux Mint 22.3

Package version

6.6.3

Frequency

Always

Bug description

While the filesystem info query (statfs()) for one folder is pending, Nemo doesn't open that folder's siblings or its parent. When the query returns, all the pending windows appear at once. Folders elsewhere open normally in the meantime, and the UI stays responsive.

I ran into it with an rclone mount on my Desktop. After a network change its statfs() took 5 minutes to answer. For those 5 minutes the folders on the desktop wouldn't open, the mount among them, and a Nemo window wouldn't show the Desktop folder either. Then they all opened together.

Steps to reproduce
  1. Save this as slowstatfs.c. It is an empty FUSE filesystem where only statfs() is slow:
slowstatfs.c
/* Empty FUSE filesystem where only statfs() is slow.
 * gcc slowstatfs.c -o slowstatfs $(pkg-config fuse3 --cflags --libs)
 * SLOW=120 ./slowstatfs <mountpoint>
 */
#define FUSE_USE_VERSION 31
#include <fuse.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

static int slow_getattr(const char *path, struct stat *st, struct fuse_file_info *fi)
{
    if (strcmp(path, "/") != 0)
        return -ENOENT;
    memset(st, 0, sizeof *st);
    st->st_mode = S_IFDIR | 0755;
    st->st_nlink = 2;
    return 0;
}

static int slow_readdir(const char *path, void *buf, fuse_fill_dir_t fill, off_t off,
                        struct fuse_file_info *fi, enum fuse_readdir_flags flags)
{
    fill(buf, ".", NULL, 0, 0);
    fill(buf, "..", NULL, 0, 0);
    return 0;
}

static int slow_statfs(const char *path, struct statvfs *st)
{
    sleep(atoi(getenv("SLOW") ? getenv("SLOW") : "120"));
    memset(st, 0, sizeof *st);
    st->f_bsize = st->f_frsize = 4096;
    st->f_namemax = 255;
    return 0;
}

static const struct fuse_operations ops = {
    .getattr = slow_getattr,
    .readdir = slow_readdir,
    .statfs = slow_statfs,
};

int main(int argc, char *argv[])
{
    return fuse_main(argc, argv, &ops, NULL);
}
  1. Build and mount it (needs libfuse3-dev):
gcc slowstatfs.c -o slowstatfs $(pkg-config fuse3 --cflags --libs)
mkdir -p ~/statfs-test/slow ~/statfs-test/a ~/other-test
SLOW=60 ./slowstatfs ~/statfs-test/slow
  1. Open the folders, a few seconds apart:
nemo ~/statfs-test/slow &    # no window
nemo ~/statfs-test/a &       # sibling: no window
nemo ~/statfs-test &         # parent: no window
nemo ~/other-test &          # unrelated folder: opens right away

About 60 s after the first command, the three missing windows appear at once. ls -la ~/statfs-test and stat ~/statfs-test/slow are instant the whole time.

  1. Unmount with fusermount3 -uz ~/statfs-test/slow.
Expected behavior

Only the folder whose query is pending should have to wait. Its siblings and its parent should open normally.

Additional information

Time after the first command at which each window appeared, in seconds. The commands were run at 0, 5, 8 and 11 s. Both versions were built from source on Ubuntu 24.04, master at 7df652f:

Command 6.6.3 master
nemo ~/statfs-test/slow (0 s) 62.5 60.7
nemo ~/statfs-test/a (5 s) 62.5 60.7
nemo ~/statfs-test (8 s) 62.5 60.7
nemo ~/other-test (11 s) 11.4 11.2

While it waits, Nemo has one thread inside statfs() and its main thread is idle in poll(). strace -f -tt -e trace=statfs on 6.6.3 shows that the sibling's query isn't sent until the slow one returns, and that the parent's own query is answered at once (other calls omitted, PID column dropped, paths shortened, results elided):

06:36:10.081962 statfs("~/statfs-test/slow",  <unfinished ...>
06:36:15.872210 statfs("~/statfs-test", {...}) = 0
06:37:10.082529 <... statfs resumed>{...}) = 0
06:37:10.085034 statfs("~/statfs-test/a", {...}) = 0

Two things in the code seem to combine:

  • filesystem_info_start() runs one query per directory at a time, and while one is pending start_or_stop_io() stops at the first file in the low priority queue. That holds back the sibling, whose query goes through the queue of the same parent directory.
  • load_directory() waits for NEMO_FILE_ATTRIBUTE_FILESYSTEM_INFO on the folder and on the subfolders Nemo already has loaded in it before the view finishes loading. That holds back the parent: if I drop that attribute from the nemo_directory_call_when_ready() call, the parent opens right away while the sibling still waits.

This is a different path from the sidebar's synchronous disk space queries behind #3764, which froze the whole window and were removed in a7c6f70893cbf81b5b7ce667a2da185f3618245f. Here the UI keeps working, and master, which has that commit, behaves the same as 6.6.3.

Lenguaje dominante
C
Estrellas
1.6k
Forks
387
Merge medio
2 d 19 h
PR fusionados (30 d)
4

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de linuxmint/nemo

Todos los issues de linuxmint/nemo

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.