Skip to contentSkip to conversation

overlayfs entrles lost

DISCUSSION Jordi Pujol 2 participants 4 messages May 31, 2011 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

a very interesting thing that happens with overlayfs,

the find command does not list a file,
but the ls command does it,
in the parent directory data we observe that he have added new files to it and the count of files for this directory is not updated,
the find command uses the functions opendir and readdir and they not work correctly in overlayfs,

# find /tmp/live-net-remaster-probDm/chroot/usr/bin/ -name slxdecode -ls
(nothing listed)
# ls -l /tmp/live-net-remaster-probDm/chroot/usr/bin/slxdecode
-rwxr-xr-x 1 root root 58856 2011-03-30 23:24 /tmp/live-net-remaster-
probDm/chroot/usr/bin/slxdecode

Thanks,

Jordi Pujol

Live never ending Tale
GNU/Linux Live forever!
http://livenet.selfip.com

#2 lore raw
In reply to a message not in the archive

A Dimarts, 31 de maig de 2011 11:40:55, Jordi Pujol va escriure:

Quoted 4 lines
Quoted 3 lines
# ls -l /tmp/live-net-remaster-probDm/chroot/usr/bin/slxdecode
-rwxr-xr-x 1 root root 58856 2011-03-30 23:24 /tmp/live-net-remaster-
probDm/chroot/usr/bin/slxdecode

adding more info,
the inode number of that file:

# ls -dils /tmp/live-net-remaster-probDm/chroot/usr/bin/slxdecode
73833 58 -rwxr-xr-x 1 root root 58856 2011-03-30 23:24 /tmp/live-net-remaster-
probDm/chroot/usr/bin/slxdecode

Thanks,

Jordi Pujol

Live never ending Tale
GNU/Linux Live forever!
http://livenet.selfip.com

maintainer
#3 lore raw
Quoted 6 lines · Jordi Pujol

A Dimarts, 31 de maig de 2011 11:40:55, Jordi Pujol va escriure:

Quoted 4 lines
Quoted 3 lines
# ls -l /tmp/live-net-remaster-probDm/chroot/usr/bin/slxdecode
-rwxr-xr-x 1 root root 58856 2011-03-30 23:24 /tmp/live-net-remaster-
probDm/chroot/usr/bin/slxdecode
Quoted 6 lines

adding more info,
the inode number of that file:

# ls -dils /tmp/live-net-remaster-probDm/chroot/usr/bin/slxdecode
73833 58 -rwxr-xr-x 1 root root 58856 2011-03-30 23:24 /tmp/live-net-remaster-
probDm/chroot/usr/bin/slxdecode

Jordi,

Thanks again for your test results.

I was able to reproduce the problem here. It turns out to be an off-by-one error in file offset calculation, leading to missing a dentry at the start of the second (third, ...) getdents() call.

The following patch should fix it. Also pushed to the overlayfs.v9 branch, it will mirror out shortly.

Thanks,
Miklos

commit 1a2e406466599f82d61bb4acb7a303f1608478f7

Author: Miklos Szeredi <[email protected]>
Date:   Tue May 31 14:32:33 2011 +0200

ovl: fix off-by-one error in readdir

Jordi Pujol reported missing entries with find. This was caused by advancing the file position even when filler() returns with an error.

fs/overlayfs/readdir.c +5 -7
index 9b8004cf..4f0a51c 100644
@@ -334,15 +334,13 @@ static int ovl_readdir(struct file *file, void *buf, filldir_t filler)
 
 		p = list_entry(od->cursor.next, struct ovl_cache_entry, l_node);
 		off = file->f_pos;
+		if (!p->is_whiteout) {
+			over = filler(buf, p->name, p->len, off, p->ino, p->type);
+			if (over)
+				break;
+		}
 		file->f_pos++;
 		list_move(&od->cursor, &p->l_node);
-
-		if (p->is_whiteout)
-			continue;
-
-		over = filler(buf, p->name, p->len, off, p->ino, p->type);
-		if (over)
-			break;
 	}
 
 	return 0;
#4 lore raw

A Dimarts, 31 de maig de 2011 14:54:06, Miklos Szeredi va escriure:

Quoted 1 line

Thanks again for your test results.

you are welcome,

Quoted 2 lines

The following patch should fix it. Also pushed to the overlayfs.v9 branch, it will mirror out shortly.

I tested it starting a new remaster, it works !

Thanks,

Jordi Pujol

Live never ending Tale
GNU/Linux Live forever!
http://livenet.selfip.com