@@ -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 ;
@@ -1006,14 +1006,15 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)
1006
1006
}
1007
1007
EXPORT_SYMBOL (dqget );
1008
1008
1009
- static inline struct dquot * * i_dquot (struct inode * inode )
1009
+ static inline struct dquot __rcu * * i_dquot (struct inode * inode )
1010
1010
{
1011
- return inode -> i_sb -> s_op -> get_dquots (inode );
1011
+ /* Force __rcu for now until filesystems are fixed */
1012
+ return (struct dquot __rcu * * )inode -> i_sb -> s_op -> get_dquots (inode );
1012
1013
}
1013
1014
1014
1015
static int dqinit_needed (struct inode * inode , int type )
1015
1016
{
1016
- struct dquot * const * dquots ;
1017
+ struct dquot __rcu * const * dquots ;
1017
1018
int cnt ;
1018
1019
1019
1020
if (IS_NOQUOTA (inode ))
@@ -1103,14 +1104,16 @@ static void remove_dquot_ref(struct super_block *sb, int type)
1103
1104
*/
1104
1105
spin_lock (& dq_data_lock );
1105
1106
if (!IS_NOQUOTA (inode )) {
1106
- struct dquot * * dquots = i_dquot (inode );
1107
- struct dquot * dquot = dquots [type ];
1107
+ struct dquot __rcu * * dquots = i_dquot (inode );
1108
+ struct dquot * dquot = srcu_dereference_check (
1109
+ dquots [type ], & dquot_srcu ,
1110
+ lockdep_is_held (& dq_data_lock ));
1108
1111
1109
1112
#ifdef CONFIG_QUOTA_DEBUG
1110
1113
if (unlikely (inode_get_rsv_space (inode ) > 0 ))
1111
1114
reserved = 1 ;
1112
1115
#endif
1113
- dquots [type ] = NULL ;
1116
+ rcu_assign_pointer ( dquots [type ], NULL ) ;
1114
1117
if (dquot )
1115
1118
dqput (dquot );
1116
1119
}
@@ -1463,7 +1466,8 @@ static int inode_quota_active(const struct inode *inode)
1463
1466
static int __dquot_initialize (struct inode * inode , int type )
1464
1467
{
1465
1468
int cnt , init_needed = 0 ;
1466
- struct dquot * * dquots , * got [MAXQUOTAS ] = {};
1469
+ struct dquot __rcu * * dquots ;
1470
+ struct dquot * got [MAXQUOTAS ] = {};
1467
1471
struct super_block * sb = inode -> i_sb ;
1468
1472
qsize_t rsv ;
1469
1473
int ret = 0 ;
@@ -1538,20 +1542,24 @@ static int __dquot_initialize(struct inode *inode, int type)
1538
1542
if (!got [cnt ])
1539
1543
continue ;
1540
1544
if (!dquots [cnt ]) {
1541
- dquots [cnt ] = got [cnt ];
1545
+ rcu_assign_pointer ( dquots [cnt ], got [cnt ]) ;
1542
1546
got [cnt ] = NULL ;
1543
1547
/*
1544
1548
* Make quota reservation system happy if someone
1545
1549
* did a write before quota was turned on
1546
1550
*/
1547
1551
rsv = inode_get_rsv_space (inode );
1548
1552
if (unlikely (rsv )) {
1553
+ struct dquot * dquot = srcu_dereference_check (
1554
+ dquots [cnt ], & dquot_srcu ,
1555
+ lockdep_is_held (& dq_data_lock ));
1556
+
1549
1557
spin_lock (& inode -> i_lock );
1550
1558
/* Get reservation again under proper lock */
1551
1559
rsv = __inode_get_rsv_space (inode );
1552
- spin_lock (& dquots [ cnt ] -> dq_dqb_lock );
1553
- dquots [ cnt ] -> dq_dqb .dqb_rsvspace += rsv ;
1554
- spin_unlock (& dquots [ cnt ] -> dq_dqb_lock );
1560
+ spin_lock (& dquot -> dq_dqb_lock );
1561
+ dquot -> dq_dqb .dqb_rsvspace += rsv ;
1562
+ spin_unlock (& dquot -> dq_dqb_lock );
1555
1563
spin_unlock (& inode -> i_lock );
1556
1564
}
1557
1565
}
@@ -1573,7 +1581,7 @@ EXPORT_SYMBOL(dquot_initialize);
1573
1581
1574
1582
bool dquot_initialize_needed (struct inode * inode )
1575
1583
{
1576
- struct dquot * * dquots ;
1584
+ struct dquot __rcu * * dquots ;
1577
1585
int i ;
1578
1586
1579
1587
if (!inode_quota_active (inode ))
@@ -1598,21 +1606,22 @@ EXPORT_SYMBOL(dquot_initialize_needed);
1598
1606
static void __dquot_drop (struct inode * inode )
1599
1607
{
1600
1608
int cnt ;
1601
- struct dquot * * dquots = i_dquot (inode );
1609
+ struct dquot __rcu * * dquots = i_dquot (inode );
1602
1610
struct dquot * put [MAXQUOTAS ];
1603
1611
1604
1612
spin_lock (& dq_data_lock );
1605
1613
for (cnt = 0 ; cnt < MAXQUOTAS ; cnt ++ ) {
1606
- put [cnt ] = dquots [cnt ];
1607
- dquots [cnt ] = NULL ;
1614
+ put [cnt ] = srcu_dereference_check (dquots [cnt ], & dquot_srcu ,
1615
+ lockdep_is_held (& dq_data_lock ));
1616
+ rcu_assign_pointer (dquots [cnt ], NULL );
1608
1617
}
1609
1618
spin_unlock (& dq_data_lock );
1610
1619
dqput_all (put );
1611
1620
}
1612
1621
1613
1622
void dquot_drop (struct inode * inode )
1614
1623
{
1615
- struct dquot * const * dquots ;
1624
+ struct dquot __rcu * const * dquots ;
1616
1625
int cnt ;
1617
1626
1618
1627
if (IS_NOQUOTA (inode ))
@@ -1685,7 +1694,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
1685
1694
int cnt , ret = 0 , index ;
1686
1695
struct dquot_warn warn [MAXQUOTAS ];
1687
1696
int reserve = flags & DQUOT_SPACE_RESERVE ;
1688
- struct dquot * * dquots ;
1697
+ struct dquot __rcu * * dquots ;
1689
1698
struct dquot * dquot ;
1690
1699
1691
1700
if (!inode_quota_active (inode )) {
@@ -1755,7 +1764,7 @@ int dquot_alloc_inode(struct inode *inode)
1755
1764
{
1756
1765
int cnt , ret = 0 , index ;
1757
1766
struct dquot_warn warn [MAXQUOTAS ];
1758
- struct dquot * const * dquots ;
1767
+ struct dquot __rcu * const * dquots ;
1759
1768
struct dquot * dquot ;
1760
1769
1761
1770
if (!inode_quota_active (inode ))
@@ -1800,7 +1809,7 @@ EXPORT_SYMBOL(dquot_alloc_inode);
1800
1809
*/
1801
1810
int dquot_claim_space_nodirty (struct inode * inode , qsize_t number )
1802
1811
{
1803
- struct dquot * * dquots ;
1812
+ struct dquot __rcu * * dquots ;
1804
1813
struct dquot * dquot ;
1805
1814
int cnt , index ;
1806
1815
@@ -1842,7 +1851,7 @@ EXPORT_SYMBOL(dquot_claim_space_nodirty);
1842
1851
*/
1843
1852
void dquot_reclaim_space_nodirty (struct inode * inode , qsize_t number )
1844
1853
{
1845
- struct dquot * * dquots ;
1854
+ struct dquot __rcu * * dquots ;
1846
1855
struct dquot * dquot ;
1847
1856
int cnt , index ;
1848
1857
@@ -1886,7 +1895,7 @@ void __dquot_free_space(struct inode *inode, qsize_t number, int flags)
1886
1895
{
1887
1896
unsigned int cnt ;
1888
1897
struct dquot_warn warn [MAXQUOTAS ];
1889
- struct dquot * * dquots ;
1898
+ struct dquot __rcu * * dquots ;
1890
1899
struct dquot * dquot ;
1891
1900
int reserve = flags & DQUOT_SPACE_RESERVE , index ;
1892
1901
@@ -1943,7 +1952,7 @@ void dquot_free_inode(struct inode *inode)
1943
1952
{
1944
1953
unsigned int cnt ;
1945
1954
struct dquot_warn warn [MAXQUOTAS ];
1946
- struct dquot * const * dquots ;
1955
+ struct dquot __rcu * const * dquots ;
1947
1956
struct dquot * dquot ;
1948
1957
int index ;
1949
1958
@@ -1990,6 +1999,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
1990
1999
qsize_t cur_space ;
1991
2000
qsize_t rsv_space = 0 ;
1992
2001
qsize_t inode_usage = 1 ;
2002
+ struct dquot __rcu * * dquots ;
1993
2003
struct dquot * transfer_from [MAXQUOTAS ] = {};
1994
2004
int cnt , index , ret = 0 ;
1995
2005
char is_valid [MAXQUOTAS ] = {};
@@ -2022,6 +2032,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2022
2032
}
2023
2033
cur_space = __inode_get_bytes (inode );
2024
2034
rsv_space = __inode_get_rsv_space (inode );
2035
+ dquots = i_dquot (inode );
2025
2036
/*
2026
2037
* Build the transfer_from list, check limits, and update usage in
2027
2038
* the target structures.
@@ -2036,7 +2047,8 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2036
2047
if (!sb_has_quota_active (inode -> i_sb , cnt ))
2037
2048
continue ;
2038
2049
is_valid [cnt ] = 1 ;
2039
- transfer_from [cnt ] = i_dquot (inode )[cnt ];
2050
+ transfer_from [cnt ] = srcu_dereference_check (dquots [cnt ],
2051
+ & dquot_srcu , lockdep_is_held (& dq_data_lock ));
2040
2052
ret = dquot_add_inodes (transfer_to [cnt ], inode_usage ,
2041
2053
& warn_to [cnt ]);
2042
2054
if (ret )
@@ -2075,7 +2087,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2075
2087
rsv_space );
2076
2088
spin_unlock (& transfer_from [cnt ]-> dq_dqb_lock );
2077
2089
}
2078
- i_dquot ( inode ) [cnt ] = transfer_to [cnt ];
2090
+ rcu_assign_pointer ( dquots [cnt ], transfer_to [cnt ]) ;
2079
2091
}
2080
2092
spin_unlock (& inode -> i_lock );
2081
2093
spin_unlock (& dq_data_lock );
@@ -2086,8 +2098,8 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2086
2098
* mark_all_dquot_dirty().
2087
2099
*/
2088
2100
index = srcu_read_lock (& dquot_srcu );
2089
- mark_all_dquot_dirty (transfer_from );
2090
- mark_all_dquot_dirty (transfer_to );
2101
+ mark_all_dquot_dirty (( struct dquot __rcu * * ) transfer_from );
2102
+ mark_all_dquot_dirty (( struct dquot __rcu * * ) transfer_to );
2091
2103
srcu_read_unlock (& dquot_srcu , index );
2092
2104
2093
2105
flush_warnings (warn_to );
0 commit comments