diff options
Diffstat (limited to 'fs/quota/dquot.c')
| -rw-r--r-- | fs/quota/dquot.c | 288 |
1 files changed, 156 insertions, 132 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index cd6bb9a33c13..dea86abdf2e7 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
| @@ -323,6 +323,30 @@ int dquot_mark_dquot_dirty(struct dquot *dquot) | |||
| 323 | } | 323 | } |
| 324 | EXPORT_SYMBOL(dquot_mark_dquot_dirty); | 324 | EXPORT_SYMBOL(dquot_mark_dquot_dirty); |
| 325 | 325 | ||
| 326 | /* Dirtify all the dquots - this can block when journalling */ | ||
| 327 | static inline int mark_all_dquot_dirty(struct dquot * const *dquot) | ||
| 328 | { | ||
| 329 | int ret, err, cnt; | ||
| 330 | |||
| 331 | ret = err = 0; | ||
| 332 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
| 333 | if (dquot[cnt]) | ||
| 334 | /* Even in case of error we have to continue */ | ||
| 335 | ret = mark_dquot_dirty(dquot[cnt]); | ||
| 336 | if (!err) | ||
| 337 | err = ret; | ||
| 338 | } | ||
| 339 | return err; | ||
| 340 | } | ||
| 341 | |||
| 342 | static inline void dqput_all(struct dquot **dquot) | ||
| 343 | { | ||
| 344 | unsigned int cnt; | ||
| 345 | |||
| 346 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
| 347 | dqput(dquot[cnt]); | ||
| 348 | } | ||
| 349 | |||
| 326 | /* This function needs dq_list_lock */ | 350 | /* This function needs dq_list_lock */ |
| 327 | static inline int clear_dquot_dirty(struct dquot *dquot) | 351 | static inline int clear_dquot_dirty(struct dquot *dquot) |
| 328 | { | 352 | { |
| @@ -1268,8 +1292,7 @@ int dquot_initialize(struct inode *inode, int type) | |||
| 1268 | out_err: | 1292 | out_err: |
| 1269 | up_write(&sb_dqopt(sb)->dqptr_sem); | 1293 | up_write(&sb_dqopt(sb)->dqptr_sem); |
| 1270 | /* Drop unused references */ | 1294 | /* Drop unused references */ |
| 1271 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1295 | dqput_all(got); |
| 1272 | dqput(got[cnt]); | ||
| 1273 | return ret; | 1296 | return ret; |
| 1274 | } | 1297 | } |
| 1275 | EXPORT_SYMBOL(dquot_initialize); | 1298 | EXPORT_SYMBOL(dquot_initialize); |
| @@ -1288,9 +1311,7 @@ int dquot_drop(struct inode *inode) | |||
| 1288 | inode->i_dquot[cnt] = NULL; | 1311 | inode->i_dquot[cnt] = NULL; |
| 1289 | } | 1312 | } |
| 1290 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1313 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1291 | 1314 | dqput_all(put); | |
| 1292 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
| 1293 | dqput(put[cnt]); | ||
| 1294 | return 0; | 1315 | return 0; |
| 1295 | } | 1316 | } |
| 1296 | EXPORT_SYMBOL(dquot_drop); | 1317 | EXPORT_SYMBOL(dquot_drop); |
| @@ -1319,6 +1340,67 @@ void vfs_dq_drop(struct inode *inode) | |||
| 1319 | EXPORT_SYMBOL(vfs_dq_drop); | 1340 | EXPORT_SYMBOL(vfs_dq_drop); |
| 1320 | 1341 | ||
| 1321 | /* | 1342 | /* |
| 1343 | * inode_reserved_space is managed internally by quota, and protected by | ||
| 1344 | * i_lock similar to i_blocks+i_bytes. | ||
| 1345 | */ | ||
| 1346 | static qsize_t *inode_reserved_space(struct inode * inode) | ||
| 1347 | { | ||
| 1348 | /* Filesystem must explicitly define it's own method in order to use | ||
| 1349 | * quota reservation interface */ | ||
| 1350 | BUG_ON(!inode->i_sb->dq_op->get_reserved_space); | ||
| 1351 | return inode->i_sb->dq_op->get_reserved_space(inode); | ||
| 1352 | } | ||
| 1353 | |||
| 1354 | static void inode_add_rsv_space(struct inode *inode, qsize_t number) | ||
| 1355 | { | ||
| 1356 | spin_lock(&inode->i_lock); | ||
| 1357 | *inode_reserved_space(inode) += number; | ||
| 1358 | spin_unlock(&inode->i_lock); | ||
| 1359 | } | ||
| 1360 | |||
| 1361 | |||
| 1362 | static void inode_claim_rsv_space(struct inode *inode, qsize_t number) | ||
| 1363 | { | ||
| 1364 | spin_lock(&inode->i_lock); | ||
| 1365 | *inode_reserved_space(inode) -= number; | ||
| 1366 | __inode_add_bytes(inode, number); | ||
| 1367 | spin_unlock(&inode->i_lock); | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | static void inode_sub_rsv_space(struct inode *inode, qsize_t number) | ||
| 1371 | { | ||
| 1372 | spin_lock(&inode->i_lock); | ||
| 1373 | *inode_reserved_space(inode) -= number; | ||
| 1374 | spin_unlock(&inode->i_lock); | ||
| 1375 | } | ||
| 1376 | |||
| 1377 | static qsize_t inode_get_rsv_space(struct inode *inode) | ||
| 1378 | { | ||
| 1379 | qsize_t ret; | ||
| 1380 | spin_lock(&inode->i_lock); | ||
| 1381 | ret = *inode_reserved_space(inode); | ||
| 1382 | spin_unlock(&inode->i_lock); | ||
| 1383 | return ret; | ||
| 1384 | } | ||
| 1385 | |||
| 1386 | static void inode_incr_space(struct inode *inode, qsize_t number, | ||
| 1387 | int reserve) | ||
| 1388 | { | ||
| 1389 | if (reserve) | ||
| 1390 | inode_add_rsv_space(inode, number); | ||
| 1391 | else | ||
| 1392 | inode_add_bytes(inode, number); | ||
| 1393 | } | ||
| 1394 | |||
| 1395 | static void inode_decr_space(struct inode *inode, qsize_t number, int reserve) | ||
| 1396 | { | ||
| 1397 | if (reserve) | ||
| 1398 | inode_sub_rsv_space(inode, number); | ||
| 1399 | else | ||
| 1400 | inode_sub_bytes(inode, number); | ||
| 1401 | } | ||
| 1402 | |||
| 1403 | /* | ||
| 1322 | * Following four functions update i_blocks+i_bytes fields and | 1404 | * Following four functions update i_blocks+i_bytes fields and |
| 1323 | * quota information (together with appropriate checks) | 1405 | * quota information (together with appropriate checks) |
| 1324 | * NOTE: We absolutely rely on the fact that caller dirties | 1406 | * NOTE: We absolutely rely on the fact that caller dirties |
| @@ -1336,6 +1418,21 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, | |||
| 1336 | int cnt, ret = QUOTA_OK; | 1418 | int cnt, ret = QUOTA_OK; |
| 1337 | char warntype[MAXQUOTAS]; | 1419 | char warntype[MAXQUOTAS]; |
| 1338 | 1420 | ||
| 1421 | /* | ||
| 1422 | * First test before acquiring mutex - solves deadlocks when we | ||
| 1423 | * re-enter the quota code and are already holding the mutex | ||
| 1424 | */ | ||
| 1425 | if (IS_NOQUOTA(inode)) { | ||
| 1426 | inode_incr_space(inode, number, reserve); | ||
| 1427 | goto out; | ||
| 1428 | } | ||
| 1429 | |||
| 1430 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1431 | if (IS_NOQUOTA(inode)) { | ||
| 1432 | inode_incr_space(inode, number, reserve); | ||
| 1433 | goto out_unlock; | ||
| 1434 | } | ||
| 1435 | |||
| 1339 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1436 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
| 1340 | warntype[cnt] = QUOTA_NL_NOWARN; | 1437 | warntype[cnt] = QUOTA_NL_NOWARN; |
| 1341 | 1438 | ||
| @@ -1346,7 +1443,8 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, | |||
| 1346 | if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt) | 1443 | if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt) |
| 1347 | == NO_QUOTA) { | 1444 | == NO_QUOTA) { |
| 1348 | ret = NO_QUOTA; | 1445 | ret = NO_QUOTA; |
| 1349 | goto out_unlock; | 1446 | spin_unlock(&dq_data_lock); |
| 1447 | goto out_flush_warn; | ||
| 1350 | } | 1448 | } |
| 1351 | } | 1449 | } |
| 1352 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1450 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
| @@ -1357,64 +1455,29 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, | |||
| 1357 | else | 1455 | else |
| 1358 | dquot_incr_space(inode->i_dquot[cnt], number); | 1456 | dquot_incr_space(inode->i_dquot[cnt], number); |
| 1359 | } | 1457 | } |
| 1360 | if (!reserve) | 1458 | inode_incr_space(inode, number, reserve); |
| 1361 | inode_add_bytes(inode, number); | ||
| 1362 | out_unlock: | ||
| 1363 | spin_unlock(&dq_data_lock); | 1459 | spin_unlock(&dq_data_lock); |
| 1460 | |||
| 1461 | if (reserve) | ||
| 1462 | goto out_flush_warn; | ||
| 1463 | mark_all_dquot_dirty(inode->i_dquot); | ||
| 1464 | out_flush_warn: | ||
| 1364 | flush_warnings(inode->i_dquot, warntype); | 1465 | flush_warnings(inode->i_dquot, warntype); |
| 1466 | out_unlock: | ||
| 1467 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1468 | out: | ||
| 1365 | return ret; | 1469 | return ret; |
| 1366 | } | 1470 | } |
| 1367 | 1471 | ||
| 1368 | int dquot_alloc_space(struct inode *inode, qsize_t number, int warn) | 1472 | int dquot_alloc_space(struct inode *inode, qsize_t number, int warn) |
| 1369 | { | 1473 | { |
| 1370 | int cnt, ret = QUOTA_OK; | 1474 | return __dquot_alloc_space(inode, number, warn, 0); |
| 1371 | |||
| 1372 | /* | ||
| 1373 | * First test before acquiring mutex - solves deadlocks when we | ||
| 1374 | * re-enter the quota code and are already holding the mutex | ||
| 1375 | */ | ||
| 1376 | if (IS_NOQUOTA(inode)) { | ||
| 1377 | inode_add_bytes(inode, number); | ||
| 1378 | goto out; | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1382 | if (IS_NOQUOTA(inode)) { | ||
| 1383 | inode_add_bytes(inode, number); | ||
| 1384 | goto out_unlock; | ||
| 1385 | } | ||
| 1386 | |||
| 1387 | ret = __dquot_alloc_space(inode, number, warn, 0); | ||
| 1388 | if (ret == NO_QUOTA) | ||
| 1389 | goto out_unlock; | ||
| 1390 | |||
| 1391 | /* Dirtify all the dquots - this can block when journalling */ | ||
| 1392 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
| 1393 | if (inode->i_dquot[cnt]) | ||
| 1394 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
| 1395 | out_unlock: | ||
| 1396 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1397 | out: | ||
| 1398 | return ret; | ||
| 1399 | } | 1475 | } |
| 1400 | EXPORT_SYMBOL(dquot_alloc_space); | 1476 | EXPORT_SYMBOL(dquot_alloc_space); |
| 1401 | 1477 | ||
| 1402 | int dquot_reserve_space(struct inode *inode, qsize_t number, int warn) | 1478 | int dquot_reserve_space(struct inode *inode, qsize_t number, int warn) |
| 1403 | { | 1479 | { |
| 1404 | int ret = QUOTA_OK; | 1480 | return __dquot_alloc_space(inode, number, warn, 1); |
| 1405 | |||
| 1406 | if (IS_NOQUOTA(inode)) | ||
| 1407 | goto out; | ||
| 1408 | |||
| 1409 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1410 | if (IS_NOQUOTA(inode)) | ||
| 1411 | goto out_unlock; | ||
| 1412 | |||
| 1413 | ret = __dquot_alloc_space(inode, number, warn, 1); | ||
| 1414 | out_unlock: | ||
| 1415 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1416 | out: | ||
| 1417 | return ret; | ||
| 1418 | } | 1481 | } |
| 1419 | EXPORT_SYMBOL(dquot_reserve_space); | 1482 | EXPORT_SYMBOL(dquot_reserve_space); |
| 1420 | 1483 | ||
| @@ -1455,10 +1518,7 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number) | |||
| 1455 | warn_put_all: | 1518 | warn_put_all: |
| 1456 | spin_unlock(&dq_data_lock); | 1519 | spin_unlock(&dq_data_lock); |
| 1457 | if (ret == QUOTA_OK) | 1520 | if (ret == QUOTA_OK) |
| 1458 | /* Dirtify all the dquots - this can block when journalling */ | 1521 | mark_all_dquot_dirty(inode->i_dquot); |
| 1459 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
| 1460 | if (inode->i_dquot[cnt]) | ||
| 1461 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
| 1462 | flush_warnings(inode->i_dquot, warntype); | 1522 | flush_warnings(inode->i_dquot, warntype); |
| 1463 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1523 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1464 | return ret; | 1524 | return ret; |
| @@ -1471,14 +1531,14 @@ int dquot_claim_space(struct inode *inode, qsize_t number) | |||
| 1471 | int ret = QUOTA_OK; | 1531 | int ret = QUOTA_OK; |
| 1472 | 1532 | ||
| 1473 | if (IS_NOQUOTA(inode)) { | 1533 | if (IS_NOQUOTA(inode)) { |
| 1474 | inode_add_bytes(inode, number); | 1534 | inode_claim_rsv_space(inode, number); |
| 1475 | goto out; | 1535 | goto out; |
| 1476 | } | 1536 | } |
| 1477 | 1537 | ||
| 1478 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1538 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1479 | if (IS_NOQUOTA(inode)) { | 1539 | if (IS_NOQUOTA(inode)) { |
| 1480 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1540 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1481 | inode_add_bytes(inode, number); | 1541 | inode_claim_rsv_space(inode, number); |
| 1482 | goto out; | 1542 | goto out; |
| 1483 | } | 1543 | } |
| 1484 | 1544 | ||
| @@ -1490,12 +1550,9 @@ int dquot_claim_space(struct inode *inode, qsize_t number) | |||
| 1490 | number); | 1550 | number); |
| 1491 | } | 1551 | } |
| 1492 | /* Update inode bytes */ | 1552 | /* Update inode bytes */ |
| 1493 | inode_add_bytes(inode, number); | 1553 | inode_claim_rsv_space(inode, number); |
| 1494 | spin_unlock(&dq_data_lock); | 1554 | spin_unlock(&dq_data_lock); |
| 1495 | /* Dirtify all the dquots - this can block when journalling */ | 1555 | mark_all_dquot_dirty(inode->i_dquot); |
| 1496 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
| 1497 | if (inode->i_dquot[cnt]) | ||
| 1498 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
| 1499 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1556 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1500 | out: | 1557 | out: |
| 1501 | return ret; | 1558 | return ret; |
| @@ -1503,38 +1560,9 @@ out: | |||
| 1503 | EXPORT_SYMBOL(dquot_claim_space); | 1560 | EXPORT_SYMBOL(dquot_claim_space); |
| 1504 | 1561 | ||
| 1505 | /* | 1562 | /* |
| 1506 | * Release reserved quota space | ||
| 1507 | */ | ||
| 1508 | void dquot_release_reserved_space(struct inode *inode, qsize_t number) | ||
| 1509 | { | ||
| 1510 | int cnt; | ||
| 1511 | |||
| 1512 | if (IS_NOQUOTA(inode)) | ||
| 1513 | goto out; | ||
| 1514 | |||
| 1515 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1516 | if (IS_NOQUOTA(inode)) | ||
| 1517 | goto out_unlock; | ||
| 1518 | |||
| 1519 | spin_lock(&dq_data_lock); | ||
| 1520 | /* Release reserved dquots */ | ||
| 1521 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
| 1522 | if (inode->i_dquot[cnt]) | ||
| 1523 | dquot_free_reserved_space(inode->i_dquot[cnt], number); | ||
| 1524 | } | ||
| 1525 | spin_unlock(&dq_data_lock); | ||
| 1526 | |||
| 1527 | out_unlock: | ||
| 1528 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
| 1529 | out: | ||
| 1530 | return; | ||
| 1531 | } | ||
| 1532 | EXPORT_SYMBOL(dquot_release_reserved_space); | ||
| 1533 | |||
| 1534 | /* | ||
| 1535 | * This operation can block, but only after everything is updated | 1563 | * This operation can block, but only after everything is updated |
| 1536 | */ | 1564 | */ |
| 1537 | int dquot_free_space(struct inode *inode, qsize_t number) | 1565 | int __dquot_free_space(struct inode *inode, qsize_t number, int reserve) |
| 1538 | { | 1566 | { |
| 1539 | unsigned int cnt; | 1567 | unsigned int cnt; |
| 1540 | char warntype[MAXQUOTAS]; | 1568 | char warntype[MAXQUOTAS]; |
| @@ -1543,7 +1571,7 @@ int dquot_free_space(struct inode *inode, qsize_t number) | |||
| 1543 | * re-enter the quota code and are already holding the mutex */ | 1571 | * re-enter the quota code and are already holding the mutex */ |
| 1544 | if (IS_NOQUOTA(inode)) { | 1572 | if (IS_NOQUOTA(inode)) { |
| 1545 | out_sub: | 1573 | out_sub: |
| 1546 | inode_sub_bytes(inode, number); | 1574 | inode_decr_space(inode, number, reserve); |
| 1547 | return QUOTA_OK; | 1575 | return QUOTA_OK; |
| 1548 | } | 1576 | } |
| 1549 | 1577 | ||
| @@ -1558,21 +1586,40 @@ out_sub: | |||
| 1558 | if (!inode->i_dquot[cnt]) | 1586 | if (!inode->i_dquot[cnt]) |
| 1559 | continue; | 1587 | continue; |
| 1560 | warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number); | 1588 | warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number); |
| 1561 | dquot_decr_space(inode->i_dquot[cnt], number); | 1589 | if (reserve) |
| 1590 | dquot_free_reserved_space(inode->i_dquot[cnt], number); | ||
| 1591 | else | ||
| 1592 | dquot_decr_space(inode->i_dquot[cnt], number); | ||
| 1562 | } | 1593 | } |
| 1563 | inode_sub_bytes(inode, number); | 1594 | inode_decr_space(inode, number, reserve); |
| 1564 | spin_unlock(&dq_data_lock); | 1595 | spin_unlock(&dq_data_lock); |
| 1565 | /* Dirtify all the dquots - this can block when journalling */ | 1596 | |
| 1566 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1597 | if (reserve) |
| 1567 | if (inode->i_dquot[cnt]) | 1598 | goto out_unlock; |
| 1568 | mark_dquot_dirty(inode->i_dquot[cnt]); | 1599 | mark_all_dquot_dirty(inode->i_dquot); |
| 1600 | out_unlock: | ||
| 1569 | flush_warnings(inode->i_dquot, warntype); | 1601 | flush_warnings(inode->i_dquot, warntype); |
| 1570 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1602 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1571 | return QUOTA_OK; | 1603 | return QUOTA_OK; |
| 1572 | } | 1604 | } |
| 1605 | |||
| 1606 | int dquot_free_space(struct inode *inode, qsize_t number) | ||
| 1607 | { | ||
| 1608 | return __dquot_free_space(inode, number, 0); | ||
| 1609 | } | ||
| 1573 | EXPORT_SYMBOL(dquot_free_space); | 1610 | EXPORT_SYMBOL(dquot_free_space); |
| 1574 | 1611 | ||
| 1575 | /* | 1612 | /* |
| 1613 | * Release reserved quota space | ||
| 1614 | */ | ||
| 1615 | void dquot_release_reserved_space(struct inode *inode, qsize_t number) | ||
| 1616 | { | ||
| 1617 | __dquot_free_space(inode, number, 1); | ||
| 1618 | |||
| 1619 | } | ||
| 1620 | EXPORT_SYMBOL(dquot_release_reserved_space); | ||
| 1621 | |||
| 1622 | /* | ||
| 1576 | * This operation can block, but only after everything is updated | 1623 | * This operation can block, but only after everything is updated |
| 1577 | */ | 1624 | */ |
| 1578 | int dquot_free_inode(const struct inode *inode, qsize_t number) | 1625 | int dquot_free_inode(const struct inode *inode, qsize_t number) |
| @@ -1599,10 +1646,7 @@ int dquot_free_inode(const struct inode *inode, qsize_t number) | |||
| 1599 | dquot_decr_inodes(inode->i_dquot[cnt], number); | 1646 | dquot_decr_inodes(inode->i_dquot[cnt], number); |
| 1600 | } | 1647 | } |
| 1601 | spin_unlock(&dq_data_lock); | 1648 | spin_unlock(&dq_data_lock); |
| 1602 | /* Dirtify all the dquots - this can block when journalling */ | 1649 | mark_all_dquot_dirty(inode->i_dquot); |
| 1603 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
| 1604 | if (inode->i_dquot[cnt]) | ||
| 1605 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
| 1606 | flush_warnings(inode->i_dquot, warntype); | 1650 | flush_warnings(inode->i_dquot, warntype); |
| 1607 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1651 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1608 | return QUOTA_OK; | 1652 | return QUOTA_OK; |
| @@ -1610,19 +1654,6 @@ int dquot_free_inode(const struct inode *inode, qsize_t number) | |||
| 1610 | EXPORT_SYMBOL(dquot_free_inode); | 1654 | EXPORT_SYMBOL(dquot_free_inode); |
| 1611 | 1655 | ||
| 1612 | /* | 1656 | /* |
| 1613 | * call back function, get reserved quota space from underlying fs | ||
| 1614 | */ | ||
| 1615 | qsize_t dquot_get_reserved_space(struct inode *inode) | ||
| 1616 | { | ||
| 1617 | qsize_t reserved_space = 0; | ||
| 1618 | |||
| 1619 | if (sb_any_quota_active(inode->i_sb) && | ||
| 1620 | inode->i_sb->dq_op->get_reserved_space) | ||
| 1621 | reserved_space = inode->i_sb->dq_op->get_reserved_space(inode); | ||
| 1622 | return reserved_space; | ||
| 1623 | } | ||
| 1624 | |||
| 1625 | /* | ||
| 1626 | * Transfer the number of inode and blocks from one diskquota to an other. | 1657 | * Transfer the number of inode and blocks from one diskquota to an other. |
| 1627 | * | 1658 | * |
| 1628 | * This operation can block, but only after everything is updated | 1659 | * This operation can block, but only after everything is updated |
| @@ -1665,7 +1696,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
| 1665 | } | 1696 | } |
| 1666 | spin_lock(&dq_data_lock); | 1697 | spin_lock(&dq_data_lock); |
| 1667 | cur_space = inode_get_bytes(inode); | 1698 | cur_space = inode_get_bytes(inode); |
| 1668 | rsv_space = dquot_get_reserved_space(inode); | 1699 | rsv_space = inode_get_rsv_space(inode); |
| 1669 | space = cur_space + rsv_space; | 1700 | space = cur_space + rsv_space; |
| 1670 | /* Build the transfer_from list and check the limits */ | 1701 | /* Build the transfer_from list and check the limits */ |
| 1671 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1702 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
| @@ -1709,25 +1740,18 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
| 1709 | spin_unlock(&dq_data_lock); | 1740 | spin_unlock(&dq_data_lock); |
| 1710 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1741 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
| 1711 | 1742 | ||
| 1712 | /* Dirtify all the dquots - this can block when journalling */ | 1743 | mark_all_dquot_dirty(transfer_from); |
| 1713 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1744 | mark_all_dquot_dirty(transfer_to); |
| 1714 | if (transfer_from[cnt]) | 1745 | /* The reference we got is transferred to the inode */ |
| 1715 | mark_dquot_dirty(transfer_from[cnt]); | 1746 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
| 1716 | if (transfer_to[cnt]) { | 1747 | transfer_to[cnt] = NULL; |
| 1717 | mark_dquot_dirty(transfer_to[cnt]); | ||
| 1718 | /* The reference we got is transferred to the inode */ | ||
| 1719 | transfer_to[cnt] = NULL; | ||
| 1720 | } | ||
| 1721 | } | ||
| 1722 | warn_put_all: | 1748 | warn_put_all: |
| 1723 | flush_warnings(transfer_to, warntype_to); | 1749 | flush_warnings(transfer_to, warntype_to); |
| 1724 | flush_warnings(transfer_from, warntype_from_inodes); | 1750 | flush_warnings(transfer_from, warntype_from_inodes); |
| 1725 | flush_warnings(transfer_from, warntype_from_space); | 1751 | flush_warnings(transfer_from, warntype_from_space); |
| 1726 | put_all: | 1752 | put_all: |
| 1727 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1753 | dqput_all(transfer_from); |
| 1728 | dqput(transfer_from[cnt]); | 1754 | dqput_all(transfer_to); |
| 1729 | dqput(transfer_to[cnt]); | ||
| 1730 | } | ||
| 1731 | return ret; | 1755 | return ret; |
| 1732 | over_quota: | 1756 | over_quota: |
| 1733 | spin_unlock(&dq_data_lock); | 1757 | spin_unlock(&dq_data_lock); |
