@@ -147,7 +147,7 @@ int cachefiles_add_cache(struct cachefiles_cache *cache)
147147 pr_info ("File cache on %s registered\n" , cache_cookie -> name );
148148
149149 /* check how much space the cache has */
150- cachefiles_has_space (cache , 0 , 0 );
150+ cachefiles_has_space (cache , 0 , 0 , cachefiles_has_space_check );
151151 cachefiles_end_secure (cache , saved_cred );
152152 _leave (" = 0 [%px]" , cache -> cache );
153153 return 0 ;
@@ -175,7 +175,8 @@ int cachefiles_add_cache(struct cachefiles_cache *cache)
175175 * cache
176176 */
177177int cachefiles_has_space (struct cachefiles_cache * cache ,
178- unsigned fnr , unsigned bnr )
178+ unsigned fnr , unsigned bnr ,
179+ enum cachefiles_has_space_for reason )
179180{
180181 struct kstatfs stats ;
181182 u64 b_avail , b_writing ;
@@ -233,7 +234,7 @@ int cachefiles_has_space(struct cachefiles_cache *cache,
233234 ret = - ENOBUFS ;
234235 if (stats .f_ffree < cache -> fstop ||
235236 b_avail < cache -> bstop )
236- goto begin_cull ;
237+ goto stop_and_begin_cull ;
237238
238239 ret = 0 ;
239240 if (stats .f_ffree < cache -> fcull ||
@@ -252,6 +253,17 @@ int cachefiles_has_space(struct cachefiles_cache *cache,
252253 //_leave(" = 0");
253254 return 0 ;
254255
256+ stop_and_begin_cull :
257+ switch (reason ) {
258+ case cachefiles_has_space_for_write :
259+ fscache_count_no_write_space ();
260+ break ;
261+ case cachefiles_has_space_for_create :
262+ fscache_count_no_create_space ();
263+ break ;
264+ default :
265+ break ;
266+ }
255267begin_cull :
256268 if (!test_and_set_bit (CACHEFILES_CULLING , & cache -> flags )) {
257269 _debug ("### CULL CACHE ###" );
0 commit comments