From: Andreas Dilger Subject: Re: [PATCH 2.6.27.y 04/11] ext4: Add percpu dirty block accounting. Date: Tue, 16 Mar 2010 12:48:03 -0600 Message-ID: References: <1268699165-17461-1-git-send-email-tytso@mit.edu> <1268699165-17461-5-git-send-email-tytso@mit.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_/l4HKDXtVa5fQUSC6bmPkw)" Cc: "K. V K.V" , ext4 development To: "Theodore Ts'o" Return-path: Received: from sca-es-mail-2.Sun.COM ([192.18.43.133]:52178 "EHLO sca-es-mail-2.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755290Ab0CPSsJ (ORCPT ); Tue, 16 Mar 2010 14:48:09 -0400 Received: from fe-sfbay-10.sun.com ([192.18.43.129]) by sca-es-mail-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id o2GIm73k009811 for ; Tue, 16 Mar 2010 11:48:08 -0700 (PDT) Received: from conversion-daemon.fe-sfbay-10.sun.com by fe-sfbay-10.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) id <0KZE00H00134K100@fe-sfbay-10.sun.com> for linux-ext4@vger.kernel.org; Tue, 16 Mar 2010 11:48:07 -0700 (PDT) In-reply-to: <1268699165-17461-5-git-send-email-tytso@mit.edu> Sender: linux-ext4-owner@vger.kernel.org List-ID: --Boundary_(ID_/l4HKDXtVa5fQUSC6bmPkw) Content-type: text/plain; CHARSET=US-ASCII; delsp=yes; format=flowed Content-transfer-encoding: 7BIT On 2010-03-15, at 18:25, Theodore Ts'o wrote: > int ext4_claim_free_blocks(struct ext4_sb_info *sbi, > ext4_fsblk_t nblocks) > { > + if (free_blocks - (nblocks + root_blocks + dirty_blocks) < > + EXT4_FREEBLOCKS_WATERMARK) { > + free_blocks = percpu_counter_sum(fbc); > + dirty_blocks = percpu_counter_sum(dbc); > + if (dirty_blocks < 0) { > + printk(KERN_CRIT "Dirty block accounting " > + "went wrong %lld\n", > + dirty_blocks); Just looking at this old patch, and noticed this is still the same in newer versions. This should probably be either an ext4_error(), since it affects data correctness, even though it isn't an on-disk error, or at least an ext4_msg() so that it also prints the block device and uses the standard ext4 error format. As it stands, this error doesn't indicate that it is an ext4 error, or which filesystem is involved, so it isn't very useful to the sysadmin. I don't think it is needed for the .stable release, but would be good for the next kernel. In the first patch (ext4-claim-err.diff) the access to the superblock for ext4_msg() is a bit of a hack, but I think it isn't terrible. The second patch (ext4-error-cleanup.diff, to be used instead of the first one) is a bit more thorough cleanup that changes the callers to pass a struct super_block, and also removes some single-use stack variables in related code. Cheers, Andreas -- Andreas Dilger Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc. --Boundary_(ID_/l4HKDXtVa5fQUSC6bmPkw) Content-type: application/octet-stream; name=ext4-claim-err.diff; x-unix-mode=0644 Content-transfer-encoding: BASE64 Content-disposition: attachment; filename=ext4-claim-err.diff VXNlIGEgc3RhbmRhcmQgZXh0NCBlcnJvciBtZXNzYWdlIGZvcm1hdCBmb3IgZXh0 NF9oYXNfZnJlZV9ibG9ja3MoKS4NCg0KU2lnbmVkLW9mZi1ieTogQW5kcmVhcyBE aWxnZXIgPGFkaWxnZXJAc3VuLmNvbT4NCg0KLS0tIC4vZnMvZXh0NC9iYWxsb2Mu Yy5vcmlnCTIwMDktMDktMDkgMTY6MTM6NTkuMDAwMDAwMDAwIC0wNjAwDQorKysg Li9mcy9leHQ0L2JhbGxvYy5jCTIwMTAtMDMtMTYgMTA6NTc6NTAuMDAwMDAwMDAw IC0wNjAwDQpAQCAtNTU5LDkgKzU1OSw5IEBAIGludCBleHQ0X2hhc19mcmVlX2Js b2NrcyhzdHJ1Y3QgZXh0NF9zYl8NCiAJCWZyZWVfYmxvY2tzICA9IHBlcmNwdV9j b3VudGVyX3N1bV9wb3NpdGl2ZShmYmMpOw0KIAkJZGlydHlfYmxvY2tzID0gcGVy Y3B1X2NvdW50ZXJfc3VtX3Bvc2l0aXZlKGRiYyk7DQogCQlpZiAoZGlydHlfYmxv Y2tzIDwgMCkgew0KLQkJCXByaW50ayhLRVJOX0NSSVQgIkRpcnR5IGJsb2NrIGFj Y291bnRpbmcgIg0KLQkJCQkJIndlbnQgd3JvbmcgJWxsZFxuIiwNCi0JCQkJCShs b25nIGxvbmcpZGlydHlfYmxvY2tzKTsNCisJCQlleHQ0X21zZyhzYmktPnNfYnVk ZHlfY2FjaGUtPmlfc2IsIEtFUk5fQ1JJVCwNCisJCQkJICJEaXJ0eSBibG9jayBh Y2NvdW50aW5nIHdlbnQgd3Jvbmc6ICVsbGRcbiIsDQorCQkJCSAobG9uZyBsb25n KWRpcnR5X2Jsb2Nrcyk7DQogCQl9DQogCX0NCiAJLyogQ2hlY2sgd2hldGhlciB3 ZSBoYXZlIHNwYWNlIGFmdGVyDQo= --Boundary_(ID_/l4HKDXtVa5fQUSC6bmPkw) Content-type: application/octet-stream; name=ext4-error-cleanup.diff; x-unix-mode=0644 Content-transfer-encoding: BASE64 Content-disposition: attachment; filename=ext4-error-cleanup.diff UGFzcyBzdHJ1Y3Qgc3VwZXJibG9jayB0byBleHQ0X2hhc19mcmVlX2Jsb2Nrcygp IHNvIHRoYXQgaXQgY2FuIHVzZSBleHQ0X21zZygpDQpmb3IgdGhlIGVycm9yIG1l c3NhZ2UsIGFuZCBtYXJrIHN0YXRpYywgc2luY2UgaXQgaXMgb25seSB1c2VkIGlu c2lkZSBiYWxsb2MuYy4NCg0KU2lnbmVkLW9mZi1ieTogQW5kcmVhcyBEaWxnZXIg PGFkaWxnZXJAc3VuLmNvbT4NCg0KLS0tIC4vZnMvZXh0NC9iYWxsb2MuYy5vcmln CTIwMDktMDktMDkgMTY6MTM6NTkuMDAwMDAwMDAwIC0wNjAwDQorKysgLi9mcy9l eHQ0L2JhbGxvYy5jCTIwMTAtMDMtMTYgMTI6MTM6MTcuMDAwMDAwMDAwIC0wNjAw DQpAQCAtNTM4LDE1ICs1MzgsMTYgQEAgdm9pZCBleHQ0X2ZyZWVfYmxvY2tzKGh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