MCPcopy Create free account
hub / github.com/ceph/ceph / _open

Method _open

src/client/Client.cc:10971–11097  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10969}
10970
10971int Client::_open(const InodeRef& in, int flags, mode_t mode, Fh **fhp,
10972 const UserPerm& perms)
10973{
10974 if (in->snapid != CEPH_NOSNAP &&
10975 (flags & (O_WRONLY | O_RDWR | O_CREAT | O_TRUNC | O_APPEND))) {
10976 return -EROFS;
10977 }
10978
10979 // use normalized flags to generate cmode
10980 int cflags = ceph_flags_sys2wire(flags);
10981 if (cct->_conf.get_val<bool>("client_force_lazyio"))
10982 cflags |= CEPH_O_LAZY;
10983
10984 int cmode = ceph_flags_to_mode(cflags);
10985
10986 int want = ceph_caps_for_mode(cmode);
10987 int result = 0;
10988
10989#if defined(__linux__)
10990 FSCryptKeyHandlerRef kh;
10991 get_keyhandler(in->fscrypt_ctx, kh);
10992 if (kh) {
10993 auto& di = kh->get_di();
10994 if (di) {
10995 di->add_inode(in->ino);
10996 }
10997 }
10998#endif
10999 in->get_open_ref(cmode); // make note of pending open, since it effects _wanted_ caps.
11000
11001 int do_sync = true;
11002 if ((flags & O_TRUNC) == 0 && in->caps_issued_mask(want)) {
11003 int mask = MAY_READ;
11004
11005 if (cmode & CEPH_FILE_MODE_WR) {
11006 mask |= MAY_WRITE;
11007 }
11008
11009 std::string path;
11010 if (make_absolute_path_string(in, path)) {
11011 ldout(cct, 20) << __func__ << " absolute path: " << path << dendl;
11012 result = mds_check_access(path, perms, mask);
11013 if (result) {
11014 return result;
11015 }
11016 // update wanted?
11017 check_caps(in, CHECK_CAPS_NODELAY);
11018 do_sync = false;
11019 }
11020 }
11021
11022 if (do_sync) {
11023 MetaRequest *req = new MetaRequest(CEPH_MDS_OP_OPEN);
11024 filepath path;
11025 in->make_nosnap_relative_path(path);
11026 req->set_filepath(path);
11027 req->head.args.open.flags = cflags & ~CEPH_O_CREAT;
11028 req->head.args.open.mode = mode;

Callers

nothing calls this directly

Calls 15

ceph_flags_sys2wireFunction · 0.85
ceph_flags_to_modeFunction · 0.85
ceph_caps_for_modeFunction · 0.85
cpp_strerrorFunction · 0.85
get_open_refMethod · 0.80
caps_issued_maskMethod · 0.80
set_inodeMethod · 0.80
del_inodeMethod · 0.80
put_open_refMethod · 0.80
make_requestFunction · 0.50
add_inodeMethod · 0.45

Tested by

no test coverage detected