[PATCH 1/3] byteorder: move le32_add_cpu friends from OCFS2 to core
- move inline functions which add native byte order variable to little/big endian variable to core header * le16_add_cpu(__le16 *var, u16 val) * le32_add_cpu(__le32 *var, u32 val) * le64_add_cpu(__le64 *var, u64 val) * be32_add_cpu(__be32 *var, u32 val) - add for completeness: * be16_add_cpu(__be16 *var, u16 val) * be64_add_cpu(__be64 *var, u64 val) Signed-off-by: Marcin Slusarz [EMAIL PROTECTED] CC: Mark Fasheh [EMAIL PROTECTED] --- fs/ocfs2/cluster/endian.h | 30 fs/ocfs2/cluster/nodemanager.c|1 - fs/ocfs2/dlm/dlmast.c |1 - fs/ocfs2/endian.h | 45 - fs/ocfs2/ocfs2.h |1 - include/linux/byteorder/generic.h | 30 6 files changed, 30 insertions(+), 78 deletions(-) delete mode 100644 fs/ocfs2/cluster/endian.h delete mode 100644 fs/ocfs2/endian.h diff --git a/fs/ocfs2/cluster/endian.h b/fs/ocfs2/cluster/endian.h deleted file mode 100644 index 2df9082..000 --- a/fs/ocfs2/cluster/endian.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2005 Oracle. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - */ - -#ifndef OCFS2_CLUSTER_ENDIAN_H -#define OCFS2_CLUSTER_ENDIAN_H - -static inline void be32_add_cpu(__be32 *var, u32 val) -{ - *var = cpu_to_be32(be32_to_cpu(*var) + val); -} - -#endif /* OCFS2_CLUSTER_ENDIAN_H */ diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index af2070d..709fba2 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -24,7 +24,6 @@ #include linux/sysctl.h #include linux/configfs.h -#include endian.h #include tcp.h #include nodemanager.h #include heartbeat.h diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c index 2fd8bde..644bee5 100644 --- a/fs/ocfs2/dlm/dlmast.c +++ b/fs/ocfs2/dlm/dlmast.c @@ -43,7 +43,6 @@ #include cluster/heartbeat.h #include cluster/nodemanager.h #include cluster/tcp.h -#include cluster/endian.h #include dlmapi.h #include dlmcommon.h diff --git a/fs/ocfs2/endian.h b/fs/ocfs2/endian.h deleted file mode 100644 index 1942e09..000 --- a/fs/ocfs2/endian.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2005 Oracle. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - */ - -#ifndef OCFS2_ENDIAN_H -#define OCFS2_ENDIAN_H - -static inline void le16_add_cpu(__le16 *var, u16 val) -{ - *var = cpu_to_le16(le16_to_cpu(*var) + val); -} - -static inline void le32_add_cpu(__le32 *var, u32 val) -{ - *var = cpu_to_le32(le32_to_cpu(*var) + val); -} - -static inline void le64_add_cpu(__le64 *var, u64 val) -{ - *var = cpu_to_le64(le64_to_cpu(*var) + val); -} - -static inline void be32_add_cpu(__be32 *var, u32 val) -{ - *var = cpu_to_be32(be32_to_cpu(*var) + val); -} - -#endif /* OCFS2_ENDIAN_H */ diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 60a23e1..cda15fd 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -43,7 +43,6 @@ #include dlm/dlmapi.h #include ocfs2_fs.h -#include endian.h #include ocfs2_lockid.h /* Most user visible OCFS2 inodes will have very few pieces of diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h index 3dc715b..d377155 100644 --- a/include/linux/byteorder/generic.h +++ b/include/linux/byteorder/generic.h @@ -146,6 +146,36 @@ #define htons(x) ___htons(x) #define
[PATCH 2/3] ext3: replace all adds to little endians variables with le*_add_cpu
replace all: little_endian_variable = cpu_to_leX(leX_to_cpu(little_endian_variable) + expression_in_cpu_byteorder); with: leX_add_cpu(little_endian_variable, expression_in_cpu_byteorder); sparse didn't generate any new warning with this patch Signed-off-by: Marcin Slusarz [EMAIL PROTECTED] --- fs/ext3/balloc.c |7 ++- fs/ext3/ialloc.c | 12 fs/ext3/resize.c | 12 fs/ext3/super.c |2 +- fs/ext3/xattr.c |6 ++ 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index a8ba7e8..89f320f 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c @@ -566,9 +566,7 @@ do_more: jbd_unlock_bh_state(bitmap_bh); spin_lock(sb_bgl_lock(sbi, block_group)); - desc-bg_free_blocks_count = - cpu_to_le16(le16_to_cpu(desc-bg_free_blocks_count) + - group_freed); + le16_add_cpu(desc-bg_free_blocks_count, group_freed); spin_unlock(sb_bgl_lock(sbi, block_group)); percpu_counter_add(sbi-s_freeblocks_counter, count); @@ -1630,8 +1628,7 @@ allocated: ret_block, goal_hits, goal_attempts); spin_lock(sb_bgl_lock(sbi, group_no)); - gdp-bg_free_blocks_count = - cpu_to_le16(le16_to_cpu(gdp-bg_free_blocks_count)-num); + le16_add_cpu(gdp-bg_free_blocks_count, -num); spin_unlock(sb_bgl_lock(sbi, group_no)); percpu_counter_sub(sbi-s_freeblocks_counter, num); diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 1bc8cd8..3b6b9da 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c @@ -164,11 +164,9 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) if (gdp) { spin_lock(sb_bgl_lock(sbi, block_group)); - gdp-bg_free_inodes_count = cpu_to_le16( - le16_to_cpu(gdp-bg_free_inodes_count) + 1); + le16_add_cpu(gdp-bg_free_inodes_count, 1); if (is_directory) - gdp-bg_used_dirs_count = cpu_to_le16( - le16_to_cpu(gdp-bg_used_dirs_count) - 1); + le16_add_cpu(gdp-bg_used_dirs_count, -1); spin_unlock(sb_bgl_lock(sbi, block_group)); percpu_counter_inc(sbi-s_freeinodes_counter); if (is_directory) @@ -527,11 +525,9 @@ got: err = ext3_journal_get_write_access(handle, bh2); if (err) goto fail; spin_lock(sb_bgl_lock(sbi, group)); - gdp-bg_free_inodes_count = - cpu_to_le16(le16_to_cpu(gdp-bg_free_inodes_count) - 1); + le16_add_cpu(gdp-bg_free_inodes_count, -1); if (S_ISDIR(mode)) { - gdp-bg_used_dirs_count = - cpu_to_le16(le16_to_cpu(gdp-bg_used_dirs_count) + 1); + le16_add_cpu(gdp-bg_used_dirs_count, 1); } spin_unlock(sb_bgl_lock(sbi, group)); BUFFER_TRACE(bh2, call ext3_journal_dirty_metadata); diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c index 44de145..5b402a7 100644 --- a/fs/ext3/resize.c +++ b/fs/ext3/resize.c @@ -518,8 +518,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, EXT3_SB(sb)-s_gdb_count++; kfree(o_group_desc); - es-s_reserved_gdt_blocks = - cpu_to_le16(le16_to_cpu(es-s_reserved_gdt_blocks) - 1); + le16_add_cpu(es-s_reserved_gdt_blocks, -1); ext3_journal_dirty_metadata(handle, EXT3_SB(sb)-s_sbh); return 0; @@ -891,10 +890,8 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input) * blocks/inodes before the group is live won't actually let us * allocate the new space yet. */ - es-s_blocks_count = cpu_to_le32(le32_to_cpu(es-s_blocks_count) + - input-blocks_count); - es-s_inodes_count = cpu_to_le32(le32_to_cpu(es-s_inodes_count) + - EXT3_INODES_PER_GROUP(sb)); + le32_add_cpu(es-s_blocks_count, input-blocks_count); + le32_add_cpu(es-s_inodes_count, EXT3_INODES_PER_GROUP(sb)); /* * We need to protect s_groups_count against other CPUs seeing @@ -927,8 +924,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input) /* Update the reserved block counts only once the new group is * active. */ - es-s_r_blocks_count = cpu_to_le32(le32_to_cpu(es-s_r_blocks_count) + - input-reserved_blocks); + le32_add_cpu(es-s_r_blocks_count, input-reserved_blocks); /* Update the free space counts */ percpu_counter_add(sbi-s_freeblocks_counter, diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 92f03b6..70da5a3 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1224,7 +1224,7 @@ static int ext3_setup_super(struct super_block *sb,
[PATCH 3/3] xfs: convert beX_add to beX_add_cpu (new common API)
remove beX_add functions and replace all uses with beX_add_cpu Signed-off-by: Marcin Slusarz [EMAIL PROTECTED] --- fs/xfs/quota/xfs_qm.c |6 ++-- fs/xfs/quota/xfs_trans_dquot.c |6 ++-- fs/xfs/xfs_alloc.c | 16 +++--- fs/xfs/xfs_alloc_btree.c | 16 +++--- fs/xfs/xfs_arch.h | 15 - fs/xfs/xfs_attr_leaf.c | 46 fs/xfs/xfs_bmap_btree.c| 16 +++--- fs/xfs/xfs_da_btree.c | 14 ++-- fs/xfs/xfs_dir2_block.c|8 +++--- fs/xfs/xfs_dir2_data.c |4 +- fs/xfs/xfs_dir2_leaf.c | 16 +++--- fs/xfs/xfs_dir2_node.c | 18 +++--- fs/xfs/xfs_fsops.c |4 +- fs/xfs/xfs_ialloc.c| 12 +- fs/xfs/xfs_ialloc_btree.c | 16 +++--- fs/xfs/xfs_trans.c | 24 ++-- 16 files changed, 111 insertions(+), 126 deletions(-) diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index d488645..791ba5d 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c @@ -1650,14 +1650,14 @@ xfs_qm_quotacheck_dqadjust( * Adjust the inode count and the block count to reflect this inode's * resource usage. */ - be64_add(dqp-q_core.d_icount, 1); + be64_add_cpu(dqp-q_core.d_icount, 1); dqp-q_res_icount++; if (nblks) { - be64_add(dqp-q_core.d_bcount, nblks); + be64_add_cpu(dqp-q_core.d_bcount, nblks); dqp-q_res_bcount += nblks; } if (rtblks) { - be64_add(dqp-q_core.d_rtbcount, rtblks); + be64_add_cpu(dqp-q_core.d_rtbcount, rtblks); dqp-q_res_rtbcount += rtblks; } diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c index 7de6874..f441f83 100644 --- a/fs/xfs/quota/xfs_trans_dquot.c +++ b/fs/xfs/quota/xfs_trans_dquot.c @@ -421,13 +421,13 @@ xfs_trans_apply_dquot_deltas( (xfs_qcnt_t) -qtrx-qt_icount_delta); #endif if (totalbdelta) - be64_add(d-d_bcount, (xfs_qcnt_t)totalbdelta); + be64_add_cpu(d-d_bcount, (xfs_qcnt_t)totalbdelta); if (qtrx-qt_icount_delta) - be64_add(d-d_icount, (xfs_qcnt_t)qtrx-qt_icount_delta); + be64_add_cpu(d-d_icount, (xfs_qcnt_t)qtrx-qt_icount_delta); if (totalrtbdelta) - be64_add(d-d_rtbcount, (xfs_qcnt_t)totalrtbdelta); + be64_add_cpu(d-d_rtbcount, (xfs_qcnt_t)totalrtbdelta); /* * Get any default limits in use. diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 012a649..139cc57 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c @@ -592,7 +592,7 @@ xfs_alloc_ag_vextent( if (!(args-wasfromfl)) { agf = XFS_BUF_TO_AGF(args-agbp); - be32_add(agf-agf_freeblks, -(args-len)); + be32_add_cpu(agf-agf_freeblks, -(args-len)); xfs_trans_agblocks_delta(args-tp, -((long)(args-len))); args-pag-pagf_freeblks -= args-len; @@ -1720,7 +1720,7 @@ xfs_free_ag_extent( agf = XFS_BUF_TO_AGF(agbp); pag = mp-m_perag[agno]; - be32_add(agf-agf_freeblks, len); + be32_add_cpu(agf-agf_freeblks, len); xfs_trans_agblocks_delta(tp, len); pag-pagf_freeblks += len; XFS_WANT_CORRUPTED_GOTO( @@ -2008,18 +2008,18 @@ xfs_alloc_get_freelist( * Get the block number and update the data structures. */ bno = be32_to_cpu(agfl-agfl_bno[be32_to_cpu(agf-agf_flfirst)]); - be32_add(agf-agf_flfirst, 1); + be32_add_cpu(agf-agf_flfirst, 1); xfs_trans_brelse(tp, agflbp); if (be32_to_cpu(agf-agf_flfirst) == XFS_AGFL_SIZE(mp)) agf-agf_flfirst = 0; pag = mp-m_perag[be32_to_cpu(agf-agf_seqno)]; - be32_add(agf-agf_flcount, -1); + be32_add_cpu(agf-agf_flcount, -1); xfs_trans_agflist_delta(tp, -1); pag-pagf_flcount--; logflags = XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT; if (btreeblk) { - be32_add(agf-agf_btreeblks, 1); + be32_add_cpu(agf-agf_btreeblks, 1); pag-pagf_btreeblks++; logflags |= XFS_AGF_BTREEBLKS; } @@ -2117,17 +2117,17 @@ xfs_alloc_put_freelist( be32_to_cpu(agf-agf_seqno), agflbp))) return error; agfl = XFS_BUF_TO_AGFL(agflbp); - be32_add(agf-agf_fllast, 1); + be32_add_cpu(agf-agf_fllast, 1);
[PATCH 0/3] byteorder: introduce le32_add_cpu friends to core
Hi This patchset moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core header (1st), converts ext3 filesystem to this API (2nd) and replaces XFS different named functions with new ones (3rd). There are many places where these functions will be useful. Just look at: grep -r 'cpu_to_[ble12346]*([ble12346]*_to_cpu.*[-+]' linux-src/ Patch for ext3 is an example how conversions will probably look like. ps: this patchset depends on http://lkml.org/lkml/2007/12/25/35 (which is in ocfs2 git tree, branches: trivial, ALL) Marcin Slusarz - To unsubscribe from this list: send the line unsubscribe linux-ext4 in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] [Coding Style]: misc fixes for fs/ext{3,4}/acl.{c,h} from checkpatch.pl
On Jan 4 2008 19:39, Theodore Tso wrote: On Sat, Jan 05, 2008 at 01:12:44AM +0100, Paolo Ciarrocchi wrote: But because running some kind of mechanical script and fixing up the problems is relatively mindless, it doesn't *add* anything. Only the maintainer knows when it is a reasonably convenient time to fix all of the problems, or when to fix portions of the code that is being reworked anyway --- and the maintainer can just run the script by himself, for himself. I have to agree. Best use of checkpatch is right before submitting, uh, a patch actually. The option that makes it work on non-patch files should be, hm, hidden or removed. - To unsubscribe from this list: send the line unsubscribe linux-ext4 in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Bug 9692] New: journal_data mount option causes filesystem corruption with blocksize != 4096
On Sat, 5 Jan 2008 09:52:15 -0800 (PST) [EMAIL PROTECTED] wrote: http://bugzilla.kernel.org/show_bug.cgi?id=9692 Summary: journal_data mount option causes filesystem corruption with blocksize != 4096 Product: File System Version: 2.5 KernelVersion: 2.6.23.9 Platform: All OS/Version: Linux Tree: Mainline Status: NEW Severity: high Priority: P1 Component: ext3 AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Most recent kernel where this bug did not occur: - Older kernels have this problem too (I think I noticed this booting = 2.6.21, definitely 2.6.22). I'm getting the feeling that we should just disable data=journal. Make it use data=ordered mode instead. It isn't getting a lot of attention.. Distribution: Gentoo Linux x86 This bug seems to be hardware-independent (tested on three different machines which all use quite different drivers). If you need hardware information or any other log or configuration files, let me know please. Problem Description: When creating an ext3 filesystem with journal_data option and block sizes different than 4096 (tested: 1024, 2048) filesystem corruption will occur if certain operations are performed (see below). Corruption will not occur if 4096 block size is used, or if any other block size is used together with journal_data_ordered or journal_data_writeback. No errors in dmesg. Steps to reproduce: I found this bug using an audio file tagger, so you need exfalso which is part of quodlibet (http://www.sacredchao.net/quodlibet/). No other file tagger I used produced this kind of problem. Still, this has to be a kernel problem, right?? 1. Create ext3 file system: mkfs.ext3 -O has_journal,dir_index -b 1024 /dev/sdd1 tune2fs -c 0 -i 0 -m 0 -o journal_data /dev/sdd1 tune2fs 1.40.3 (05-Dec-2007) (filtered) Filesystem volume name: none Last mounted on: not available Filesystem magic number: 0xEF53 Filesystem revision #:1 (dynamic) Filesystem features: has_journal resize_inode dir_index filetype sparse_super Filesystem flags: signed directory hash Default mount options:journal_data Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 126976 Block count: 1012060 Reserved block count: 0 Free blocks: 976865 Free inodes: 126965 First block: 1 Block size: 1024 Fragment size:1024 Reserved GDT blocks: 256 Blocks per group: 8192 Fragments per group: 8192 Inodes per group: 1024 Inode blocks per group: 128 Last mount time: n/a Mount count: 0 Maximum mount count: -1 Check interval: 0 (none) Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode:8 Default directory hash: tea Journal backup: inode blocks 2. Mount it and copy mp3,ogg,... files to it. This does not cause any file system corruption (which you can confirm by running fsck). pmount /dev/sdd1: /dev/sdd1 on /media/sdd1 type ext3 (rw,noexec,nosuid,nodev,errors=continue) 3. Use quodlibet/exfalso to change the id3 tags. Add tags to it if not present, or delete them if already present. This will lead to file system corruption. brw-r- 1 root disk 8, 49 /dev/sdd1 4. Unmount the volume. pumount /dev/sdd1 5. Run fsck -fvD /dev/sdd1. It will complain about wrong i_size. e2fsck 1.40.3 (05-Dec-2007) Pass 1: Checking inodes, blocks, and sizes Inode 47106, i_size is 5015509, should be 5017600. Fixy? yes Inode 47107, i_size is 4657736, should be 4661248. Fixy? yes Inode 47109, i_size is 11928555, should be 11931648. Fixy? yes Inode 47111, i_size is 5698454, should be 5701632. Fixy? yes Inode 47112, i_size is 9384018, should be 9388032. Fixy? yes Inode 47114, i_size is 5679228, should be 5681152. Fixy? yes Inode 47115, i_size is 6107218, should be 6111232. Fixy? yes Inode 47117, i_size is 4354297, should be 4358144. Fixy? yes Inode 47118, i_size is 4512286, should be 4513792. Fixy? yes Inode 47120, i_size is 7010846, should be 7012352. Fixy? yes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 3A: Optimizing directories Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdd1: * FILE SYSTEM WAS MODIFIED * 28 inodes used (0.02%) 14 non-contiguous inodes (50.0%) # of inodes with ind/dind/tind blocks: 15/15/0 123417 blocks used (12.19%) 0 bad blocks 0 large files 16 regular files 3 directories 0 character device files 0 block device