Re: ERROR: (device sda2): dbDiscardAG [jfs]: no memory for trim array

Dave Kleikamp <[email protected]> Wed, 24 Jan 2018 08:50:16 -0600
Newsgroups gmane.comp.file-systems.jfs.general
Message-ID <[email protected]>
On 01/24/2018 07:39 AM, Per Jessen wrote:
> On an office desktop system, I see quite a few of $SUBJ.  
> I was wondering what it means? 

It looks like jfs is trying to make too large a memory allocation in
dbDiscardAG().

It would be smarter to call kmalloc with __GFP_NOWARN and try again with
a smaller array until it succeeds.

This would be a quick and dirty workaround:

diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 2d514c7affc2..4cb6cb864703 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -1640,7 +1640,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
 	nblocks = bmp->db_agfree[agno];
 	max_ranges = nblocks;
 	do_div(max_ranges, minlen);
-	range_cnt = min_t(u64, max_ranges + 1, 32 * 1024);
+	range_cnt = min_t(u64, max_ranges + 1, 4 * 1024);
 	totrim = kmalloc(sizeof(struct range2trim) * range_cnt, GFP_NOFS);
 	if (totrim == NULL) {
 		jfs_error(bmp->db_ipbmap->i_sb, "no memory for trim array\n");


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot