diff options
author | Sage Weil <sage@newdream.net> | 2011-09-01 09:50:25 -0700 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-09-01 11:23:49 -0700 |
commit | 886440d3c38189761a8655593f3b32869ff7c60c (patch) | |
tree | 06cc6e4a9bdff23bbf84ed0639f0982ef8640ba5 | |
parent | b71f3bc756ca156db6d624802980700b8a1ea840 (diff) | |
download | ceph-886440d3c38189761a8655593f3b32869ff7c60c.tar.gz |
client: clean up _{create,release}_fh
Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r-- | src/client/Client.cc | 59 | ||||
-rw-r--r-- | src/client/Client.h | 2 |
2 files changed, 29 insertions, 32 deletions
diff --git a/src/client/Client.cc b/src/client/Client.cc index bb2cfb90c43..444e6df7179 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3279,7 +3279,7 @@ void Client::unmount() // NOTE: i'm assuming all caches are already flushing (because all files are closed). - //clean up any unclosed files + // clean up any unclosed files if (!fd_map.empty()) std::cerr << "Warning: Some files were not closed prior to unmounting;\n" << "Ceph is closing them now.\n"; @@ -3287,7 +3287,8 @@ void Client::unmount() int fd = fd_map.begin()->first; assert(fd_map.count(fd)); Fh *fh = fd_map[fd]; - _release(fh); + lderr(cct) << " destroying lost open file " << fh << " on " << *fh->inode << dendl; + _release_fh(fh); fd_map.erase(fd); } @@ -4823,6 +4824,29 @@ Fh *Client::_create_fh(Inode *in, int flags, int cmode) return f; } +int Client::_release_fh(Fh *f) +{ + //ldout(cct, 3) << "op: client->close(open_files[ " << fh << " ]);" << dendl; + //ldout(cct, 3) << "op: open_files.erase( " << fh << " );" << dendl; + Inode *in = f->inode; + ldout(cct, 5) << "_release_fh " << f << " mode " << f->mode << " on " << *in << dendl; + + if (in->snapid == CEPH_NOSNAP) { + if (in->put_open_ref(f->mode)) { + _flush(in); + check_caps(in, false); + } + } else { + assert(in->snap_cap_refs > 0); + in->snap_cap_refs--; + } + + put_inode( in ); + delete f; + + return 0; +} + int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid, int gid) { int cmode = ceph_flags_to_mode(flags); @@ -4866,9 +4890,6 @@ int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid, int gid) return result; } - - - int Client::close(int fd) { ldout(cct, 3) << "close enter(" << fd << ")" << dendl; @@ -4878,36 +4899,12 @@ int Client::close(int fd) assert(fd_map.count(fd)); Fh *fh = fd_map[fd]; - _release(fh); + _release_fh(fh); fd_map.erase(fd); ldout(cct, 3) << "close exit(" << fd << ")" << dendl; return 0; } -int Client::_release(Fh *f) -{ - //ldout(cct, 3) << "op: client->close(open_files[ " << fh << " ]);" << dendl; - //ldout(cct, 3) << "op: open_files.erase( " << fh << " );" << dendl; - Inode *in = f->inode; - ldout(cct, 5) << "_release " << f << " mode " << f->mode << " on " << *in << dendl; - - if (in->snapid == CEPH_NOSNAP) { - if (in->put_open_ref(f->mode)) { - _flush(in); - check_caps(in, false); - } - } else { - assert(in->snap_cap_refs > 0); - in->snap_cap_refs--; - } - - put_inode( in ); - delete f; - - return 0; -} - - // ------------ // read, write @@ -6735,7 +6732,7 @@ int Client::ll_release(Fh *fh) tout(cct) << "ll_release" << std::endl; tout(cct) << (unsigned long)fh << std::endl; - _release(fh); + _release_fh(fh); return 0; } diff --git a/src/client/Client.h b/src/client/Client.h index c094082c92f..f4a5f1404f7 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -467,6 +467,7 @@ private: void _ll_drop_pins(); Fh *_create_fh(Inode *in, int flags, int cmode); + int _release_fh(Fh *fh); int _read_sync(Fh *f, uint64_t off, uint64_t len, bufferlist *bl); int _read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl); @@ -491,7 +492,6 @@ private: int _removexattr(Inode *in, const char *nm, int uid=-1, int gid=-1); int _open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid=-1, int gid=-1); int _create(Inode *in, const char *name, int flags, mode_t mode, Inode **inp, Fh **fhp, int uid=-1, int gid=-1); - int _release(Fh *fh); loff_t _lseek(Fh *fh, loff_t offset, int whence); int _read(Fh *fh, int64_t offset, uint64_t size, bufferlist *bl); int _write(Fh *fh, int64_t offset, uint64_t size, const char *buf); |