Skip to content

Commit 8c28f3e

Browse files
author
chenjinhao
committed
posix_create: make sure _fd that passed to posix_fdstat is valid
Make sure _fd that passed to posix_fdstat is always valid even if posix_create_link_if_gfid_exists is called. Signed-off-by: chenjinhao <[email protected]>
1 parent 693cd1c commit 8c28f3e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

xlators/storage/posix/src/posix-entry-ops.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,21 @@ posix_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
24622462
loc->inode->table);
24632463
if (!op_ret) {
24642464
linked = _gf_true;
2465-
goto post_op;
2465+
/* A vaild _fd is required in posix_fdstat, which is after post_op label.
2466+
* So, we should open this existing linkfile anyway, instead goto post_op
2467+
* directly.
2468+
*
2469+
* goto post_op;
2470+
*/
2471+
2472+
/* For an existing linkfile, we should clear unnecessary flags in _flags,
2473+
* otherwhile this file may be deleted and re-created once
2474+
* GF_FORCE_REPLACE_KEY is set and hence cause some xattr are absent.
2475+
*/
2476+
if (_flags & O_CREAT)
2477+
_flags &= ~O_CREAT;
2478+
if (_flags & O_EXCL)
2479+
_flags &= ~O_EXCL;
24662480
}
24672481
}
24682482
real_op:

0 commit comments

Comments
 (0)