linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* open_dev_excl in reshape_container() fails
@ 2011-01-13 15:40 Kwolek, Adam
  2011-01-13 17:27 ` Dan Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Kwolek, Adam @ 2011-01-13 15:40 UTC (permalink / raw)
  To: neilb@suse.de
  Cc: linux-raid@vger.kernel.org, Neubauer, Wojciech, Kwolek, Adam,
	Williams, Dan J, Ciechanowski, Ed

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-17  4:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-13 15:40 open_dev_excl in reshape_container() fails Kwolek, Adam
2011-01-13 17:27 ` Dan Williams
2011-01-14  7:31   ` Kwolek, Adam
2011-01-14 10:36     ` Kwolek, Adam
2011-01-14 22:49       ` Dan Williams
2011-01-17  4:07       ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).