--- linux-stage/fs/ext4/mballoc.c 2016-11-25 04:15:25.824396109 +0530 +++ linux-stage.orig/fs/ext4/mballoc.c 2016-11-25 02:59:13.505151246 +0530 @@ -3594,6 +3594,11 @@ unsigned short max = EXT4_CLUSTERS_PER_GROUP(sb); unsigned short i, first, free = 0; +#ifdef HAVE_CLEAR_RDONLY_ON_PUT + /* be quiet if readonly device */ + if (dev_check_rdonly(sb->s_bdev)) + return 0; +#endif i = mb_find_next_zero_bit(bitmap, max, 0); while (i < max) { @@ -3969,6 +3974,14 @@ bit = next + 1; } + +#ifdef HAVE_CLEAR_RDONLY_ON_PUT + /* be quiet if readonly device */ + if (dev_check_rdonly(sb->s_bdev)) { + atomic_add(free, &sbi->s_mb_discarded); + return err; + } +#endif /* "free < pa->pa_free" means we maybe double alloc the same blocks, * otherwise maybe leave some free blocks unavailable, no need to BUG.*/ if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {