Skip to contentSkip to conversation

quota: add missing use of dq_data_lock in __dquot_initialize

PATCH In review Jeff Mahoney 2 participants 2 messages Feb 27, 2013 – Mar 1, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 quota: add missing use of dq_data_lock in __dquot_initialize

The bulk of __dquot_initialize runs under the dqptr_sem which protects the inode->i_dquot pointers. It doesn't protect the dereferenced contents, though. Those are protected by the dq_data_lock, which is missing around the dquot_resv_space call.

--

 fs/quota/dquot.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/quota/dquot.c +4 -1
@@ -1439,8 +1439,11 @@ static void __dquot_initialize(struct in
 			 * did a write before quota was turned on
 			 */
 			rsv = inode_get_rsv_space(inode);
-			if (unlikely(rsv))
+			if (unlikely(rsv)) {
+				spin_lock(&dq_data_lock);
 				dquot_resv_space(inode->i_dquot[cnt], rsv);
+				spin_unlock(&dq_data_lock);
+			}
 		}
 	}
 out_err:
Signature · 2 lines
Jeff Mahoney
SUSE Labs
reviewer
#1 lore raw
Quoted 7 lines · Jeff Mahoney

The bulk of __dquot_initialize runs under the dqptr_sem which protects the inode->i_dquot pointers. It doesn't protect the dereferenced contents, though. Those are protected by the dq_data_lock, which is missing around the dquot_resv_space call.

Thanks! I've merged the patch. Just one small nitpick - git(1) expects
diffstat to be separated by three dashes (not two) so I had to fix that up so that it doesn't appear in the commit message. Not sure how that happened in your submission but I wanted to point that out just in case it was some systematic error...

Honza

Quoted 28 lines

--

 fs/quota/dquot.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/quota/dquot.c +4 -1
@@ -1439,8 +1439,11 @@ static void __dquot_initialize(struct in
 			 * did a write before quota was turned on
 			 */
 			rsv = inode_get_rsv_space(inode);
-			if (unlikely(rsv))
+			if (unlikely(rsv)) {
+				spin_lock(&dq_data_lock);
 				dquot_resv_space(inode->i_dquot[cnt], rsv);
+				spin_unlock(&dq_data_lock);
+			}
 		}
 	}
 out_err:
Signature · 7 lines
-- 
Jeff Mahoney
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR