Project

General

Profile

client.patch

Zheng Yan, 07/02/2015 08:47 AM

Download (2.94 KB)

View differences:

src/civetweb
1
Subproject commit 439063547d58427efa921296aa7be107182a026c
1
Subproject commit 8a07012185851b8e8be180391866b5995c10ee93
src/client/Client.cc
254 254
       ++it) {
255 255
    Fh *fh = it->second;
256 256
    ldout(cct, 1) << "tear_down_cache forcing close of fh " << it->first << " ino " << fh->inode->ino << dendl;
257
    put_inode(fh->inode);
258
    delete fh;
257
    _release_fh(fh);
259 258
  }
260 259
  fd_map.clear();
261 260

  
......
6693 6692
    ldout(cct, 10) << "_release_fh " << f << " on inode " << *in << " no async_err state" << dendl;
6694 6693
  }
6695 6694

  
6696
  put_inode(in);
6697
  delete f;
6695
  _put_fh(f);
6698 6696

  
6699 6697
  return err;
6700 6698
}
6701 6699

  
6700
void Client::_put_fh(Fh *f)
6701
{
6702
  int left = f->put();
6703
  if (!left) {
6704
    put_inode(f->inode);
6705
    delete f;
6706
  }
6707
}
6708

  
6702 6709
int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid, int gid)
6703 6710
{
6704 6711
  int cmode = ceph_flags_to_mode(flags);
......
7038 7045
  return r < 0 ? r : bl->length();
7039 7046
}
7040 7047

  
7048
Client::C_Readahead::C_Readahead(Client *c, Fh *f) :
7049
  client(c), f(f) {
7050
    f->get();
7051
}
7052

  
7041 7053
void Client::C_Readahead::finish(int r) {
7042 7054
  lgeneric_subdout(client->cct, client, 20) << "client." << client->get_nodeid() << " " << "C_Readahead on " << f->inode << dendl;
7043 7055
  client->put_cap_ref(f->inode, CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE);
7044 7056
  f->readahead.dec_pending();
7057
  client->_put_fh(f);
7045 7058
}
7046 7059

  
7047 7060
int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl)
src/client/Client.h
624 624

  
625 625
  Fh *_create_fh(Inode *in, int flags, int cmode);
626 626
  int _release_fh(Fh *fh);
627
  void _put_fh(Fh *fh);
627 628

  
628 629

  
629 630
  struct C_Readahead : public Context {
630 631
    Client *client;
631 632
    Fh *f;
632
    C_Readahead(Client *c, Fh *f)
633
      : client(c),
634
	f(f) { }
633
    C_Readahead(Client *c, Fh *f);
635 634
    void finish(int r);
636 635
  };
637 636

  
src/client/Fh.h
11 11
// file handle for any open file state
12 12

  
13 13
struct Fh {
14
  Inode    *inode;
14
  int	    _ref;
15
  Inode     *inode;
15 16
  loff_t    pos;
16 17
  int       mds;        // have to talk to mds we opened with (for now)
17 18
  int       mode;       // the mode i opened the file with
......
26 27
  ceph_lock_state_t *fcntl_locks;
27 28
  ceph_lock_state_t *flock_locks;
28 29

  
29
  Fh() : inode(0), pos(0), mds(0), mode(0), flags(0), pos_locked(false),
30
  Fh() : _ref(1), inode(0), pos(0), mds(0), mode(0), flags(0), pos_locked(false),
30 31
      readahead(), fcntl_locks(NULL), flock_locks(NULL) {}
32
  void get() { ++_ref; }
33
  int put() { return --_ref; }
31 34
};
32 35

  
33 36