@@ -197,10 +197,10 @@ void ceph_cleanup_quotarealms_inodes(struct ceph_mds_client *mdsc)
197
197
}
198
198
199
199
/*
200
- * This function walks through the snaprealm for an inode and returns the
201
- * ceph_snap_realm for the first snaprealm that has quotas set (max_files,
200
+ * This function walks through the snaprealm for an inode and set the
201
+ * realmp with the first snaprealm that has quotas set (max_files,
202
202
* max_bytes, or any, depending on the 'which_quota' argument). If the root is
203
- * reached, return the root ceph_snap_realm instead.
203
+ * reached, set the realmp with the root ceph_snap_realm instead.
204
204
*
205
205
* Note that the caller is responsible for calling ceph_put_snap_realm() on the
206
206
* returned realm.
@@ -211,19 +211,20 @@ void ceph_cleanup_quotarealms_inodes(struct ceph_mds_client *mdsc)
211
211
* this function will return -EAGAIN; otherwise, the snaprealms walk-through
212
212
* will be restarted.
213
213
*/
214
- static struct ceph_snap_realm * get_quota_realm (struct ceph_mds_client * mdsc ,
215
- struct inode * inode ,
216
- enum quota_get_realm which_quota ,
217
- bool retry )
214
+ static int get_quota_realm (struct ceph_mds_client * mdsc , struct inode * inode ,
215
+ enum quota_get_realm which_quota ,
216
+ struct ceph_snap_realm * * realmp , bool retry )
218
217
{
219
218
struct ceph_client * cl = mdsc -> fsc -> client ;
220
219
struct ceph_inode_info * ci = NULL ;
221
220
struct ceph_snap_realm * realm , * next ;
222
221
struct inode * in ;
223
222
bool has_quota ;
224
223
224
+ if (realmp )
225
+ * realmp = NULL ;
225
226
if (ceph_snap (inode ) != CEPH_NOSNAP )
226
- return NULL ;
227
+ return 0 ;
227
228
228
229
restart :
229
230
realm = ceph_inode (inode )-> i_snap_realm ;
@@ -250,7 +251,7 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
250
251
break ;
251
252
ceph_put_snap_realm (mdsc , realm );
252
253
if (!retry )
253
- return ERR_PTR ( - EAGAIN ) ;
254
+ return - EAGAIN ;
254
255
goto restart ;
255
256
}
256
257
@@ -259,8 +260,11 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
259
260
iput (in );
260
261
261
262
next = realm -> parent ;
262
- if (has_quota || !next )
263
- return realm ;
263
+ if (has_quota || !next ) {
264
+ if (realmp )
265
+ * realmp = realm ;
266
+ return 0 ;
267
+ }
264
268
265
269
ceph_get_snap_realm (mdsc , next );
266
270
ceph_put_snap_realm (mdsc , realm );
@@ -269,14 +273,15 @@ static struct ceph_snap_realm *get_quota_realm(struct ceph_mds_client *mdsc,
269
273
if (realm )
270
274
ceph_put_snap_realm (mdsc , realm );
271
275
272
- return NULL ;
276
+ return 0 ;
273
277
}
274
278
275
279
bool ceph_quota_is_same_realm (struct inode * old , struct inode * new )
276
280
{
277
281
struct ceph_mds_client * mdsc = ceph_sb_to_mdsc (old -> i_sb );
278
282
struct ceph_snap_realm * old_realm , * new_realm ;
279
283
bool is_same ;
284
+ int ret ;
280
285
281
286
restart :
282
287
/*
@@ -286,9 +291,9 @@ bool ceph_quota_is_same_realm(struct inode *old, struct inode *new)
286
291
* dropped and we can then restart the whole operation.
287
292
*/
288
293
down_read (& mdsc -> snap_rwsem );
289
- old_realm = get_quota_realm (mdsc , old , QUOTA_GET_ANY , true);
290
- new_realm = get_quota_realm (mdsc , new , QUOTA_GET_ANY , false);
291
- if (PTR_ERR ( new_realm ) == - EAGAIN ) {
294
+ get_quota_realm (mdsc , old , QUOTA_GET_ANY , & old_realm , true);
295
+ ret = get_quota_realm (mdsc , new , QUOTA_GET_ANY , & new_realm , false);
296
+ if (ret == - EAGAIN ) {
292
297
up_read (& mdsc -> snap_rwsem );
293
298
if (old_realm )
294
299
ceph_put_snap_realm (mdsc , old_realm );
@@ -492,8 +497,8 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)
492
497
bool is_updated = false;
493
498
494
499
down_read (& mdsc -> snap_rwsem );
495
- realm = get_quota_realm (mdsc , d_inode (fsc -> sb -> s_root ),
496
- QUOTA_GET_MAX_BYTES , true);
500
+ get_quota_realm (mdsc , d_inode (fsc -> sb -> s_root ), QUOTA_GET_MAX_BYTES ,
501
+ & realm , true);
497
502
up_read (& mdsc -> snap_rwsem );
498
503
if (!realm )
499
504
return false;
0 commit comments