class C_MDL_CheckMaxSize : public Context {
Locker *locker;
CInode *in;
+ bool update_size;
+ uint64_t newsize;
+ bool update_max;
+ uint64_t new_max_size;
+ utime_t mtime;
+
public:
- C_MDL_CheckMaxSize(Locker *l, CInode *i) : locker(l), in(i) {
+ C_MDL_CheckMaxSize(Locker *l, CInode *i, bool _update_size, uint64_t _newsize,
+ bool _update_max, uint64_t _new_max_size, utime_t _mtime) :
+ locker(l), in(i),
+ update_size(_update_size), newsize(_newsize),
+ update_max(_update_max), new_max_size(_new_max_size),
+ mtime(_mtime)
+ {
in->get(CInode::PIN_PTRWAITER);
}
void finish(int r) {
in->put(CInode::PIN_PTRWAITER);
if (in->is_auth())
- locker->check_inode_max_size(in);
+ locker->check_inode_max_size(in, false, update_size, newsize,
+ update_max, new_max_size, mtime);
}
};
}
bool Locker::check_inode_max_size(CInode *in, bool force_wrlock,
- bool update_size, uint64_t new_size, utime_t new_mtime)
+ bool update_size, uint64_t new_size,
+ bool update_max, uint64_t new_max_size,
+ utime_t new_mtime)
{
assert(in->is_auth());
uint64_t size = latest->size;
if (update_size)
size = new_size;
- bool new_max = false;
+ bool new_max = update_max;
+
+ uint64_t client_range_size = update_max ? new_max_size : size;
- calc_new_client_ranges(in, size, new_ranges);
+ calc_new_client_ranges(in, client_range_size, new_ranges);
if (latest->client_ranges != new_ranges)
new_max = true;
if (in->is_frozen()) {
dout(10) << "check_inode_max_size frozen, waiting on " << *in << dendl;
- in->add_waiter(CInode::WAIT_UNFREEZE, new C_MDL_CheckMaxSize(this, in));
+ C_MDL_CheckMaxSize *cms = new C_MDL_CheckMaxSize(this, in,
+ update_size, new_size,
+ update_max, new_max_size,
+ new_mtime);
+ in->add_waiter(CInode::WAIT_UNFREEZE, cms);
return false;
}
if (!force_wrlock && !in->filelock.can_wrlock(in->get_loner())) {
}
if (!in->filelock.can_wrlock(in->get_loner())) {
// try again later
- in->filelock.add_waiter(SimpleLock::WAIT_STABLE, new C_MDL_CheckMaxSize(this, in));
+ C_MDL_CheckMaxSize *cms = new C_MDL_CheckMaxSize(this, in,
+ update_size, new_size,
+ update_max, new_max_size,
+ new_mtime);
+
+ in->filelock.add_waiter(SimpleLock::WAIT_STABLE, cms);
dout(10) << "check_inode_max_size can't wrlock, waiting on " << *in << dendl;
return false;
}
}
if (!in->filelock.can_wrlock(client) &&
!in->filelock.can_force_wrlock(client)) {
- in->filelock.add_waiter(SimpleLock::WAIT_STABLE, new C_MDL_CheckMaxSize(this, in));
+ C_MDL_CheckMaxSize *cms = new C_MDL_CheckMaxSize(this, in,
+ false, 0,
+ change_max, new_max,
+ utime_t());
+
+ in->filelock.add_waiter(SimpleLock::WAIT_STABLE, cms);
change_max = false;
}
}
MClientCaps *ack);
public:
void calc_new_client_ranges(CInode *in, uint64_t size, map<client_t, client_writeable_range_t>& new_ranges);
- bool check_inode_max_size(CInode *in, bool force_wrlock=false, bool update_size=false, uint64_t newsize=0,
+ bool check_inode_max_size(CInode *in, bool force_wrlock=false,
+ bool update_size=false, uint64_t newsize=0,
+ bool update_max=false, uint64_t newmax=0,
utime_t mtime=utime_t());
void share_inode_max_size(CInode *in, Capability *only_cap=0);