-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: avoid EEXIST error and truncate if needed when opening an existing file #746
Conversation
57fb6b5
to
0ed6a7d
Compare
f9f85d9
to
1c10aa7
Compare
This PR changes @MichaelBrim , the PR is failing on a test of the client API here: UnifyFS/t/api/create-open-remove.c Lines 47 to 49 in 04fee67
I see our implementation only sets the UnifyFS/client/src/unifyfs_api_file.c Lines 86 to 88 in 04fee67
We could change this to |
The semantics of |
@MichaelBrim , I added Lines 178 to 179 in 04fee67
We indicate that the exclusive bit was set in the open flags and pass that to UnifyFS/client/src/unifyfs_fid.c Line 413 in 04fee67
UnifyFS/client/src/unifyfs_fid.c Line 443 in 04fee67
and then in UnifyFS/client/src/unifyfs_fid.c Lines 195 to 197 in 04fee67
UnifyFS/client/src/unifyfs_fid.c Line 235 in 04fee67
So we currently have two meanings for
I guess we'd need to either pick a different bit flag to indicate private files or I could revert back to handling the |
I'm a bit torn on this dilemma. I think it's useful to maintain the idea of a private (non-shared) file, although most of our usefulness to current applications comes from shared files. Using O_EXCL to mean private was always a hack, but I still can't find a better standard flag to substitute for it. If we want to maintain the private notion, the exclusive-create logic would need to live in the POSIX wrappers layer. We could funnel all open() or fopen() calls that should create files through |
3936370
to
fd28d55
Compare
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
fd28d55
to
228eb66
Compare
@MichaelBrim , I've got this about halfway done now. As it stands To avoid breaking things, I have Which The Should we throw an error if a user passes |
Since the library API assumes stateless file access, I think my conclusion is the only Also, we should define our own flag values for use in |
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
cc4f1c5
to
96e3249
Compare
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
cac0177
to
eb3b930
Compare
@MichaelBrim , this is ready for another look when you have a chance. The main changes since you last looked at it are in the client API library. I updated the API calls to use the new I think it's good to go. Let me know if you have suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had the one suggestion to remove an '#if 0'block, but otherwise looks good.
TEST_CHECKPATCH_SKIP_FILES="common/src/unifyfs_configurator.h"
310d069
to
4ae473d
Compare
Thanks, @MichaelBrim ! |
Description
This updates
unifyfs_fid_open()
to handleO_EXCL
andEEXIST
. Checks from posix wrappers are removed. It splitsunifyfs_fid_open()
into parts.unifyfs_gfid_create()
call is responsible for creating the gfid entry on the server. This does not modify the local fid cache at all.unifyfs_fid_fetch()
call retrieves file meta data for the corresponding gfid from the server. It allocates an entry in the fid cache, or if one already exists, it updates the existing cache entry.The client API library has been updated to call these new functions.
unifyfs_create()
callsunifyfs_gfid_create()
to create the gfid entry, and then it callsunifyfs_open()
.unifyfs_open()
callsunifyfs_fid_fetch()
to allocate an entry in the fid cache and populate it with data about the gfid from the server.A new
UNIFYFS_CLIENT_EXCL_PRIVATE
config option is added to toggle whetherO_EXCL
implies a private file. By default,O_EXCL
creates private files. One can create shared files usingO_EXCL
by settingUNIFYFS_CLIENT_EXCL_PRIVATE=0
.Motivation and Context
When passed the
O_CREAT
flag, anopen
call on an existing file should succeed as long asO_EXCL
is not also given. We return anEEXIST
error fromunifyfs_fid_open
when the file already exists. In ouropen
andcreat
wrappers, this is then handled as a special case where we do a second call tounifyfs_fid_open
after masking out theO_CREAT
flag.UnifyFS/client/src/unifyfs-sysio.c
Lines 1200 to 1209 in ca3fa9e
However, that special case logic is missing from our
fopen
wrapper, which fails with an error when callingfopen(name, "w")
on an existing file. This means that the following case returns anEEXIST
error when it should succeed:This refactors
unifyfs_fid_open
to simplify checking when opening laminated files, truncating files, and allocating a new local fid structure when needed.How Has This Been Tested?
Types of changes
Checklist: