plfs / plfs-core

LANL no longer develops PLFS. Feel free to fork and develop as you wish.
41 stars 36 forks source link

flatfile rename issue #358

Open chuckcranor opened 9 years ago

chuckcranor commented 9 years ago

for the flat file FS: if we have an open file and we rename it, the flatfile code may copy the backing file from one backing filesystem to another (e.g. see FlatFileSystem::rename() calls Util::CopyFile). if the file is open we have a cached IOSHandle *backend_fh in the Flat_fd ... and if Flat_fd::renamefd() is called (see FlatFileFD.h), it will update the path/backend metadata in the Flat_fd, but not the open backend_fh IOSHandle (which will point to the old backend filesystem, pre Util::CopyFile). Future I/O will go to that stale backend_fh, rather than a new fh open on the new backend location.

This only impacts FUSE (since it is the main user of renamefd()).

A possible solution is to have Flat_fd::renamefd() close the old backend_fh and reopen the backing file at the new location (making sure you open in the correct mode and get the error handling right).

chuckcranor commented 9 years ago

There is a check for this that can produce mlogs like:

MLOG ERR FlatFile: openfile rename across devs

that David S. saw from the regression test.

johnbent commented 9 years ago

On Dec 1, 2014, at 10:32 AM, chuckcranor notifications@github.com wrote:

for the flat file FS: if we have an open file and we rename it, the flatfile code may copy the backing file from one backing filesystem to another (e.g. see FlatFileSystem::rename() calls Util::CopyFile). if the file is open we have a cached IOSHandle *backend_fh in the Flat_fd ... and if Flat_fd::renamefd() is called (see FlatFileFD.h), it will update the path/backend metadata in the Flat_fd, but not the open backend_fh IOSHandle (which will point to the old backend filesystem, pre Util::CopyFile). Future I/O will go to that stale backend_fh, rather than a new fh open on the new backend location.

This only impacts FUSE (since it is the main user of renamefd()).

A possible solution is to have Flat_fd::renamefd() close the old backend_fh and reopen the backing file at the new location (making sure you open in the correct mode and get the error handling right).

Then what if a write happens in the midst of the copying? Who should win? Can we control who wins? Should we care enough to control who wins?

Thx

John

— Reply to this email directly or view it on GitHub.

chuckcranor commented 9 years ago

Ah, there's that too. Looking at the current code, i think that if you write during the copy the write data will be copied only if the Util::CopyFile hasn't done that area. Could add more locking code to block the writes during copy, though currently it isn't a common use case for us.