open_dev_excl in reshape_container() fails
From: Kwolek, Adam <hidden>
Date: 2011-01-13 15:40:32
Hi,
I've got a problem using open_dev_excl() in reshape_container(), it fails. This functions goes down
and calls open() with flags O_DIRECT| O_RDWR| O_EXCL.
It fails in reshape_container(), ealier in Grow_reshape() exactly the same test call to open_dev_excl() succeed.
Between test open and open in reshape_container() there is no other open() performed (or other i/o operation that can cause problem).
It not depends on mdmon action because it is the same for raid5 and raid0.
Function open_dev() works, and I'm using it as workaround.
In man pages for open() is told that O_EXCL flag should be used with O_CREAT flag only.
I've read in manual for open() also: "If O_EXCL is set and O_CREAT is not set, the result is undefined"
This can explain my experiences, about open_dev_excl() results.
Please let me know if above is right? What tell you your tests?
If mdadm needs some locking mechanism, probably we should use F_SETLK/F_GETLK i.e.:
int fd = open("/dev/name", <flags>);
/* To lock the file/device */
struct flock fl = { F_WRLCK, SEEK_SET, 0, 0, 0 };
fl.l_pid = getpid();
fcntl(ld, F_SETLK, &fl);
...
/ * To unlock the file/device */
struct flock fl = { F_UNLCK, SEEK_SET, 0, 0, 0 };
fl.l_pid = getpid();
fcntl(ld, F_SETLK, &fl);
...
close(fd);
Please tell me your opinion, because I think we have got a problem.
BR
Adam
-------------------------------------------------------------
Intel Technology Poland Sp. z o.o.
email: adam.kwolek@intel.com
phone: +48 58 766 1773
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html