if (wanted == 0 && !in->caps.empty()) {
in->caps.clear();
+ dout(10) << "last caps on " << *in << dendl;
put_inode(in);
}
}
dout(5) << "_release " << f << dendl;
Inode *in = f->inode;
- // update inode rd/wr counts
- int before = in->caps_wanted();
- in->put_open_ref(f->mode);
- int after = in->caps_wanted();
-
- delete f;
-
- // does this change what caps we want?
- if (before != after && after)
+ if (in->put_open_ref(f->mode))
check_caps(in);
-
put_inode( in );
+
+ delete f;
return 0;
}
// ------------
// read, write
-
off_t Client::lseek(int fd, off_t offset, int whence)
{
Mutex::Locker lock(client_lock);
}
-
void Client::lock_fh_pos(Fh *f)
{
dout(10) << "lock_fh_pos " << f << dendl;
Client *cl;
Inode *in;
public:
- C_Client_SyncCommit(Client *c, Inode *i) : cl(c), in(i) {}
+ C_Client_SyncCommit(Client *c, Inode *i) : cl(c), in(i) {
+ in->get();
+ }
void finish(int) {
cl->sync_write_commit(in);
}
Context *onsafe = new C_Client_SyncCommit(this, in);
unsafe_sync_write++;
- in->get();
in->get_cap_ref(CEPH_CAP_WRBUFFER);
filer->write(in->inode, offset, size, blist, 0,
open_by_mode[mode]++;
}
bool put_open_ref(int mode) {
+ cout << "open_by_mode[" << mode << "] " << open_by_mode[mode] << " -> " << (open_by_mode[mode]-1) << std::endl;
if (--open_by_mode[mode] == 0)
return true;
return false;
for (map<int,int>::iterator p = cap_refs.begin();
p != cap_refs.end();
p++)
- w |= p->first;
+ if (p->second)
+ w |= p->first;
return w;
}
int caps_file_wanted() {
int want = 0;
- for (int mode = 0; mode < 4; mode++)
- if (open_by_mode.count(mode) && open_by_mode[mode])
- want |= ceph_caps_for_mode(mode);
+ for (map<int,int>::iterator p = open_by_mode.begin();
+ p != open_by_mode.end();
+ p++)
+ if (p->second)
+ want |= ceph_caps_for_mode(p->first);
return want;
}
int caps_wanted() {