@@ -628,6 +628,18 @@ int dquot_scan_active(struct super_block *sb,
628628}
629629EXPORT_SYMBOL (dquot_scan_active );
630630
631+ static inline int dquot_write_dquot (struct dquot * dquot )
632+ {
633+ int ret = dquot -> dq_sb -> dq_op -> write_dquot (dquot );
634+ if (ret < 0 ) {
635+ quota_error (dquot -> dq_sb , "Can't write quota structure "
636+ "(error %d). Quota may get out of sync!" , ret );
637+ /* Clear dirty bit anyway to avoid infinite loop. */
638+ clear_dquot_dirty (dquot );
639+ }
640+ return ret ;
641+ }
642+
631643/* Write all dquot structures to quota files */
632644int dquot_writeback_dquots (struct super_block * sb , int type )
633645{
@@ -658,16 +670,9 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
658670 * use count */
659671 dqgrab (dquot );
660672 spin_unlock (& dq_list_lock );
661- err = sb -> dq_op -> write_dquot (dquot );
662- if (err ) {
663- /*
664- * Clear dirty bit anyway to avoid infinite
665- * loop here.
666- */
667- clear_dquot_dirty (dquot );
668- if (!ret )
669- ret = err ;
670- }
673+ err = dquot_write_dquot (dquot );
674+ if (err && !ret )
675+ ret = err ;
671676 dqput (dquot );
672677 spin_lock (& dq_list_lock );
673678 }
@@ -765,8 +770,6 @@ static struct shrinker dqcache_shrinker = {
765770 */
766771void dqput (struct dquot * dquot )
767772{
768- int ret ;
769-
770773 if (!dquot )
771774 return ;
772775#ifdef CONFIG_QUOTA_DEBUG
@@ -794,17 +797,7 @@ void dqput(struct dquot *dquot)
794797 if (dquot_dirty (dquot )) {
795798 spin_unlock (& dq_list_lock );
796799 /* Commit dquot before releasing */
797- ret = dquot -> dq_sb -> dq_op -> write_dquot (dquot );
798- if (ret < 0 ) {
799- quota_error (dquot -> dq_sb , "Can't write quota structure"
800- " (error %d). Quota may get out of sync!" ,
801- ret );
802- /*
803- * We clear dirty bit anyway, so that we avoid
804- * infinite loop here
805- */
806- clear_dquot_dirty (dquot );
807- }
800+ dquot_write_dquot (dquot );
808801 goto we_slept ;
809802 }
810803 if (test_bit (DQ_ACTIVE_B , & dquot -> dq_flags )) {
0 commit comments