coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"ls -l": Avoid unnecessary getxattr() overhead


From: Sven Breuner
Subject: "ls -l": Avoid unnecessary getxattr() overhead
Date: Mon, 06 Feb 2012 14:50:51 +0100
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:10.0) Gecko/20120129 Thunderbird/10.0

Hi,

when strace'ing "ls -l" on Linux, I see that it runs three syscalls for every file in the directory, e.g.:

$ strace ls -l
...
lstat("test", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lgetxattr("test", "security.selinux", 0x62d130, 255) = -1 ENODATA (No data available) getxattr("test", "system.posix_acl_access", 0x0, 0) = -1 EOPNOTSUPP (Operation not supported)

lstat("test2", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lgetxattr("test2", "security.selinux", 0x62b350, 255) = -1 ENODATA (No data available) getxattr("test2", "system.posix_acl_access", 0x0, 0) = -1 EOPNOTSUPP (Operation not supported)

lstat("test3", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lgetxattr("test3", "security.selinux", 0x62d150, 255) = -1 ENODATA (No data available) getxattr("test3", "system.posix_acl_access", 0x0, 0) = -1 EOPNOTSUPP (Operation not supported)
...

The first operation is lstat(), which definitely makes sense. The other two operations are 1) lgetxattr(..., "security.selinux", ...): Doesn't make sense imho, because selinux isn't even enabled on the system on which I ran "ls -l". 2) getxattr(..., "system.posix_acl_access", ...): Doesn't make sense, as ACLs are not supported on this file system (=> EOPNOTSUPP).

While these extra calls might not really be a problem for local file systems, they are a real pain for remote file systems, such as NFS or FhGFS (on which I'm working) and probably also for FUSE-based file systems. The problem is that these extra syscalls lead to an inode revalidation inside the (Linux) kernel and thus result in extra remote calls for every file, so it would be really great if they could be avoided after detecting that they don't make sense in a particular directory.

I don't want to start a philosophical discussion about large directories, but as a matter of fact, we often have users with tens of thousands of files inside a single directory and those users need to run "ls -l" in these directories frequently to monitor the status of thei compute job and things like that. Currently, they need to wait three times longer than necessary to see the result, due to the two extra syscalls for each file.

What I would like to suggest is detecting whether these extra calls make sense and disable them if they don't make sense: 1) For lgetxattr(..., "security.selinux", ...), ls could simply check whether selinux is enabled and skip the calls if it isn't enabled. 2) For getxattr(..., "system.posix_acl_access", ...), ls could check whether the first call returns EOPNOTSUPP and then skip this call for the remaining directory entries, because those will just have the same return value.

Best regards,
Sven

---

Sven Breuner
Fraunhofer HPC
FhGFS Team
http://www.fhgfs.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]