@@ -399,7 +399,7 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
399
399
EXPORT_SYMBOL (dquot_mark_dquot_dirty );
400
400
401
401
/* Dirtify all the dquots - this can block when journalling */
402
- static inline int mark_all_dquot_dirty (struct dquot * const * dquots )
402
+ static inline int mark_all_dquot_dirty (struct dquot __rcu * const * dquots )
403
403
{
404
404
int ret , err , cnt ;
405
405
struct dquot * dquot ;
@@ -996,14 +996,15 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)
996
996
}
997
997
EXPORT_SYMBOL (dqget );
998
998
999
- static inline struct dquot * * i_dquot (struct inode * inode )
999
+ static inline struct dquot __rcu * * i_dquot (struct inode * inode )
1000
1000
{
1001
- return inode -> i_sb -> s_op -> get_dquots (inode );
1001
+ /* Force __rcu for now until filesystems are fixed */
1002
+ return (struct dquot __rcu * * )inode -> i_sb -> s_op -> get_dquots (inode );
1002
1003
}
1003
1004
1004
1005
static int dqinit_needed (struct inode * inode , int type )
1005
1006
{
1006
- struct dquot * const * dquots ;
1007
+ struct dquot __rcu * const * dquots ;
1007
1008
int cnt ;
1008
1009
1009
1010
if (IS_NOQUOTA (inode ))
@@ -1093,14 +1094,16 @@ static void remove_dquot_ref(struct super_block *sb, int type)
1093
1094
*/
1094
1095
spin_lock (& dq_data_lock );
1095
1096
if (!IS_NOQUOTA (inode )) {
1096
- struct dquot * * dquots = i_dquot (inode );
1097
- struct dquot * dquot = dquots [type ];
1097
+ struct dquot __rcu * * dquots = i_dquot (inode );
1098
+ struct dquot * dquot = srcu_dereference_check (
1099
+ dquots [type ], & dquot_srcu ,
1100
+ lockdep_is_held (& dq_data_lock ));
1098
1101
1099
1102
#ifdef CONFIG_QUOTA_DEBUG
1100
1103
if (unlikely (inode_get_rsv_space (inode ) > 0 ))
1101
1104
reserved = 1 ;
1102
1105
#endif
1103
- dquots [type ] = NULL ;
1106
+ rcu_assign_pointer ( dquots [type ], NULL ) ;
1104
1107
if (dquot )
1105
1108
dqput (dquot );
1106
1109
}
@@ -1453,7 +1456,8 @@ static int inode_quota_active(const struct inode *inode)
1453
1456
static int __dquot_initialize (struct inode * inode , int type )
1454
1457
{
1455
1458
int cnt , init_needed = 0 ;
1456
- struct dquot * * dquots , * got [MAXQUOTAS ] = {};
1459
+ struct dquot __rcu * * dquots ;
1460
+ struct dquot * got [MAXQUOTAS ] = {};
1457
1461
struct super_block * sb = inode -> i_sb ;
1458
1462
qsize_t rsv ;
1459
1463
int ret = 0 ;
@@ -1528,20 +1532,24 @@ static int __dquot_initialize(struct inode *inode, int type)
1528
1532
if (!got [cnt ])
1529
1533
continue ;
1530
1534
if (!dquots [cnt ]) {
1531
- dquots [cnt ] = got [cnt ];
1535
+ rcu_assign_pointer ( dquots [cnt ], got [cnt ]) ;
1532
1536
got [cnt ] = NULL ;
1533
1537
/*
1534
1538
* Make quota reservation system happy if someone
1535
1539
* did a write before quota was turned on
1536
1540
*/
1537
1541
rsv = inode_get_rsv_space (inode );
1538
1542
if (unlikely (rsv )) {
1543
+ struct dquot * dquot = srcu_dereference_check (
1544
+ dquots [cnt ], & dquot_srcu ,
1545
+ lockdep_is_held (& dq_data_lock ));
1546
+
1539
1547
spin_lock (& inode -> i_lock );
1540
1548
/* Get reservation again under proper lock */
1541
1549
rsv = __inode_get_rsv_space (inode );
1542
- spin_lock (& dquots [ cnt ] -> dq_dqb_lock );
1543
- dquots [ cnt ] -> dq_dqb .dqb_rsvspace += rsv ;
1544
- spin_unlock (& dquots [ cnt ] -> dq_dqb_lock );
1550
+ spin_lock (& dquot -> dq_dqb_lock );
1551
+ dquot -> dq_dqb .dqb_rsvspace += rsv ;
1552
+ spin_unlock (& dquot -> dq_dqb_lock );
1545
1553
spin_unlock (& inode -> i_lock );
1546
1554
}
1547
1555
}
@@ -1563,7 +1571,7 @@ EXPORT_SYMBOL(dquot_initialize);
1563
1571
1564
1572
bool dquot_initialize_needed (struct inode * inode )
1565
1573
{
1566
- struct dquot * * dquots ;
1574
+ struct dquot __rcu * * dquots ;
1567
1575
int i ;
1568
1576
1569
1577
if (!inode_quota_active (inode ))
@@ -1588,21 +1596,22 @@ EXPORT_SYMBOL(dquot_initialize_needed);
1588
1596
static void __dquot_drop (struct inode * inode )
1589
1597
{
1590
1598
int cnt ;
1591
- struct dquot * * dquots = i_dquot (inode );
1599
+ struct dquot __rcu * * dquots = i_dquot (inode );
1592
1600
struct dquot * put [MAXQUOTAS ];
1593
1601
1594
1602
spin_lock (& dq_data_lock );
1595
1603
for (cnt = 0 ; cnt < MAXQUOTAS ; cnt ++ ) {
1596
- put [cnt ] = dquots [cnt ];
1597
- dquots [cnt ] = NULL ;
1604
+ put [cnt ] = srcu_dereference_check (dquots [cnt ], & dquot_srcu ,
1605
+ lockdep_is_held (& dq_data_lock ));
1606
+ rcu_assign_pointer (dquots [cnt ], NULL );
1598
1607
}
1599
1608
spin_unlock (& dq_data_lock );
1600
1609
dqput_all (put );
1601
1610
}
1602
1611
1603
1612
void dquot_drop (struct inode * inode )
1604
1613
{
1605
- struct dquot * const * dquots ;
1614
+ struct dquot __rcu * const * dquots ;
1606
1615
int cnt ;
1607
1616
1608
1617
if (IS_NOQUOTA (inode ))
@@ -1675,7 +1684,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
1675
1684
int cnt , ret = 0 , index ;
1676
1685
struct dquot_warn warn [MAXQUOTAS ];
1677
1686
int reserve = flags & DQUOT_SPACE_RESERVE ;
1678
- struct dquot * * dquots ;
1687
+ struct dquot __rcu * * dquots ;
1679
1688
struct dquot * dquot ;
1680
1689
1681
1690
if (!inode_quota_active (inode )) {
@@ -1745,7 +1754,7 @@ int dquot_alloc_inode(struct inode *inode)
1745
1754
{
1746
1755
int cnt , ret = 0 , index ;
1747
1756
struct dquot_warn warn [MAXQUOTAS ];
1748
- struct dquot * const * dquots ;
1757
+ struct dquot __rcu * const * dquots ;
1749
1758
struct dquot * dquot ;
1750
1759
1751
1760
if (!inode_quota_active (inode ))
@@ -1790,7 +1799,7 @@ EXPORT_SYMBOL(dquot_alloc_inode);
1790
1799
*/
1791
1800
void dquot_claim_space_nodirty (struct inode * inode , qsize_t number )
1792
1801
{
1793
- struct dquot * * dquots ;
1802
+ struct dquot __rcu * * dquots ;
1794
1803
struct dquot * dquot ;
1795
1804
int cnt , index ;
1796
1805
@@ -1832,7 +1841,7 @@ EXPORT_SYMBOL(dquot_claim_space_nodirty);
1832
1841
*/
1833
1842
void dquot_reclaim_space_nodirty (struct inode * inode , qsize_t number )
1834
1843
{
1835
- struct dquot * * dquots ;
1844
+ struct dquot __rcu * * dquots ;
1836
1845
struct dquot * dquot ;
1837
1846
int cnt , index ;
1838
1847
@@ -1876,7 +1885,7 @@ void __dquot_free_space(struct inode *inode, qsize_t number, int flags)
1876
1885
{
1877
1886
unsigned int cnt ;
1878
1887
struct dquot_warn warn [MAXQUOTAS ];
1879
- struct dquot * * dquots ;
1888
+ struct dquot __rcu * * dquots ;
1880
1889
struct dquot * dquot ;
1881
1890
int reserve = flags & DQUOT_SPACE_RESERVE , index ;
1882
1891
@@ -1933,7 +1942,7 @@ void dquot_free_inode(struct inode *inode)
1933
1942
{
1934
1943
unsigned int cnt ;
1935
1944
struct dquot_warn warn [MAXQUOTAS ];
1936
- struct dquot * const * dquots ;
1945
+ struct dquot __rcu * const * dquots ;
1937
1946
struct dquot * dquot ;
1938
1947
int index ;
1939
1948
@@ -1980,6 +1989,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
1980
1989
qsize_t cur_space ;
1981
1990
qsize_t rsv_space = 0 ;
1982
1991
qsize_t inode_usage = 1 ;
1992
+ struct dquot __rcu * * dquots ;
1983
1993
struct dquot * transfer_from [MAXQUOTAS ] = {};
1984
1994
int cnt , index , ret = 0 ;
1985
1995
char is_valid [MAXQUOTAS ] = {};
@@ -2012,6 +2022,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2012
2022
}
2013
2023
cur_space = __inode_get_bytes (inode );
2014
2024
rsv_space = __inode_get_rsv_space (inode );
2025
+ dquots = i_dquot (inode );
2015
2026
/*
2016
2027
* Build the transfer_from list, check limits, and update usage in
2017
2028
* the target structures.
@@ -2026,7 +2037,8 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2026
2037
if (!sb_has_quota_active (inode -> i_sb , cnt ))
2027
2038
continue ;
2028
2039
is_valid [cnt ] = 1 ;
2029
- transfer_from [cnt ] = i_dquot (inode )[cnt ];
2040
+ transfer_from [cnt ] = srcu_dereference_check (dquots [cnt ],
2041
+ & dquot_srcu , lockdep_is_held (& dq_data_lock ));
2030
2042
ret = dquot_add_inodes (transfer_to [cnt ], inode_usage ,
2031
2043
& warn_to [cnt ]);
2032
2044
if (ret )
@@ -2065,7 +2077,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2065
2077
rsv_space );
2066
2078
spin_unlock (& transfer_from [cnt ]-> dq_dqb_lock );
2067
2079
}
2068
- i_dquot ( inode ) [cnt ] = transfer_to [cnt ];
2080
+ rcu_assign_pointer ( dquots [cnt ], transfer_to [cnt ]) ;
2069
2081
}
2070
2082
spin_unlock (& inode -> i_lock );
2071
2083
spin_unlock (& dq_data_lock );
@@ -2076,8 +2088,8 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2076
2088
* mark_all_dquot_dirty().
2077
2089
*/
2078
2090
index = srcu_read_lock (& dquot_srcu );
2079
- mark_all_dquot_dirty (transfer_from );
2080
- mark_all_dquot_dirty (transfer_to );
2091
+ mark_all_dquot_dirty (( struct dquot __rcu * * ) transfer_from );
2092
+ mark_all_dquot_dirty (( struct dquot __rcu * * ) transfer_to );
2081
2093
srcu_read_unlock (& dquot_srcu , index );
2082
2094
2083
2095
flush_warnings (warn_to );
0 commit comments