return -EBADF;
}
+ if ((fh->mode & CEPH_FILE_MODE_WR) && fh->gen != fd_gen)
+ return -EBADF;
+
if ((in->flags & I_ERROR_FILELOCK) && fh->has_any_filelocks())
return -EIO;
last_auto_reconnect + 30 * 60 < now &&
cct->_conf.get_val<bool>("client_reconnect_stale")) {
messenger->client_reset();
+ fd_gen++; // invalidate open files
blacklisted = false;
_kick_stale_sessions();
last_auto_reconnect = now;
Fh *Client::_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms)
{
ceph_assert(in);
- Fh *f = new Fh(in, flags, cmode, perms);
+ Fh *f = new Fh(in, flags, cmode, fd_gen, perms);
ldout(cct, 10) << __func__ << " " << in->ino << " mode " << cmode << dendl;
if (cmode & CEPH_FILE_MODE_RD)
need |= CEPH_CAP_FILE_RD;
- Fh fh(in, flags, cmode, perms);
+ Fh fh(in, flags, cmode, fd_gen, perms);
result = get_caps(&fh, need, want, &have, -1);
if (result < 0) {
ldout(cct, 8) << "Unable to get caps after open of inode " << *in <<
ceph::unordered_map<int, Fh*> fd_map;
set<Fh*> ll_unclosed_fh_set;
ceph::unordered_set<dir_result_t*> opened_dirs;
+ uint64_t fd_gen = 1;
bool initialized = false;
bool mounted = false;
#include "Fh.h"
-Fh::Fh(InodeRef in, int flags, int cmode, const UserPerm &perms) :
- inode(in), _ref(1), pos(0), mds(0), mode(cmode), flags(flags), pos_locked(false),
- actor_perms(perms), readahead()
+Fh::Fh(InodeRef in, int flags, int cmode, uint64_t _gen, const UserPerm &perms) :
+ inode(in), _ref(1), pos(0), mds(0), mode(cmode), gen(_gen), flags(flags),
+ pos_locked(false), actor_perms(perms), readahead()
{
inode->add_fh(this);
}
loff_t pos;
int mds; // have to talk to mds we opened with (for now)
int mode; // the mode i opened the file with
+ uint64_t gen;
int flags;
bool pos_locked; // pos is currently in use
}
Fh() = delete;
- Fh(InodeRef in, int flags, int cmode, const UserPerm &perms);
+ Fh(InodeRef in, int flags, int cmode, uint64_t gen, const UserPerm &perms);
~Fh();
void get() { ++_ref; }