bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] opening files with O_NONBLOCK causes problems


From: Vitezslav Cizek
Subject: [Bug-tar] opening files with O_NONBLOCK causes problems
Date: Wed, 4 Jan 2012 16:20:30 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hello,
Opening files with O_NONBLOCK causes problems.

Here is the commit that caused the problem:

http://git.savannah.gnu.org/cgit/tar.git/commit/?id=de328a580ab6f5ff4a3237ce21f1ef0b7dd12984

Removing the O_NONBLOCK flag restores the correct behaviour.

Quoting from a bugreport by Ron Kerry:

tar opens the file with O_NONBLOCK, It issues one read which fails
predictably with EAGAIN for an offline file, It immediately closes the file
and moves on, it never retries the read.

openat(AT_FDCWD, "qsub_allocation.patch",
O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC) = 4
...
read(4, 0x654200, 2986)                 = -1 EAGAIN (Resource
temporarily unavailable)
write(2, "tar: ", 5tar: )                    = 5
write(2, "qsub_allocation.patch: Read erro"..., 69qsub_allocation.patch:
Read error at byte 0, while reading 2986 bytes) = 69
write(2, ": Resource temporarily unavailab"..., 34: Resource temporarily
unavailable) = 34
write(2, "\n", 1
)                       = 1
close(4)

There's a comment above the relevant code part:

/* Flags for accessing files to be read from or copied into. POSIX says
O_NONBLOCK has unspecified effect on most types of files, but in
practice it never harms and sometimes helps. */
{
int base_open_flags =
(O_BINARY | O_CLOEXEC | O_NOCTTY | O_NONBLOCK
| (dereference_option ? 0 : O_NOFOLLOW)
| (atime_preserve_option == system_atime_preserve ? O_NOATIME : 0));
...

Whoever wrote that is wrong, it can harm if done incorrectly. Opening an
offline file with O_NONBLOCK and issuing a read(2) tells DMF (HSM software)
to initiate recall of the file, but the O_NONBLOCK tells DMF to not block the
process, let it continue executing, because the process wants to do
something else while waiting and it will come back later and try the
read(2) again. However, tar does NOT come back and try the
read(2) again, it moves on to the next file.

-- 
Vita Cizek

Attachment: pgptxxM91w76Q.pgp
Description: PGP signature


reply via email to

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