From: Nathan Scott Date: Mon, 7 Apr 2003 00:03:34 +0000 (+0000) Subject: Sync user and kernel code, make xfs_io -f option useful. X-Git-Tag: XFS-1_3_0pre1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=321717ae517631f8ef0512bcf3f958a542a0e33e;p=thirdparty%2Fxfsprogs-dev.git Sync user and kernel code, make xfs_io -f option useful. Sync user and kernel code. --- diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 06b7b626e..a4a1cab1d 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -291,6 +291,7 @@ typedef struct xfs_mount { int m_bsize; /* fs logical block size */ xfs_agnumber_t m_agfrotor; /* last ag where space found */ xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ + lock_t m_agirotor_lock;/* .. and lock protecting it */ xfs_agnumber_t m_maxagi; /* highest inode alloc group */ int m_ihsize; /* size of next field */ struct xfs_ihash *m_ihash; /* fs private inode hash table*/ diff --git a/io/init.c b/io/init.c index 8d4731c3f..a6d2dc2ff 100644 --- a/io/init.c +++ b/io/init.c @@ -62,6 +62,7 @@ init( int argc, char **argv) { + int fflag = 0; int c; progname = basename(argv[0]); @@ -86,7 +87,8 @@ init( case 'd': /* directIO */ directio = 1; break; - case 'f': /* ignore */ + case 'f': /* create */ + fflag = 1; break; case 'p': /* progname */ progname = optarg; @@ -115,7 +117,7 @@ init( usage(); fname = strdup(argv[optind]); - if ((fdesc = openfile(fname, append, 0, directio, + if ((fdesc = openfile(fname, append, fflag, directio, readonly, osync, trunc, realtime)) < 0) exit(1); diff --git a/libxfs/xfs.h b/libxfs/xfs.h index bb281f414..6f5511212 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -274,6 +274,8 @@ typedef struct { dev_t dev; } xfs_buftarg_t; #define mraccess(a) ((void) 0) #define ismrlocked(a,b) 1 #define spinlock_init(a,b) ((void) 0) +#define spin_lock(a) ((void) 0) +#define spin_unlock(a) ((void) 0) #define __return_address __builtin_return_address(0) #define xfs_btree_reada_bufl(m,fsb,c) ((void) 0) #define xfs_btree_reada_bufs(m,fsb,c,x) ((void) 0) diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 4f0e80b80..9b19b2a90 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -339,6 +339,21 @@ xfs_ialloc_ag_alloc( return 0; } +STATIC __inline xfs_agnumber_t +xfs_ialloc_next_ag( + xfs_mount_t *mp) +{ + xfs_agnumber_t agno; + + spin_lock(&mp->m_agirotor_lock); + agno = mp->m_agirotor; + if (++mp->m_agirotor == mp->m_maxagi) + mp->m_agirotor = 0; + spin_unlock(&mp->m_agirotor_lock); + + return agno; +} + /* * Select an allocation group to look for a free inode in, based on the parent * inode and then mode. Return the allocation group buffer. @@ -369,7 +384,7 @@ xfs_ialloc_ag_select( mp = tp->t_mountp; agcount = mp->m_maxagi; if (S_ISDIR(mode)) - pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount); + pagno = xfs_ialloc_next_ag(mp); else { pagno = XFS_INO_TO_AGNO(mp, parent); if (pagno >= agcount) @@ -397,7 +412,7 @@ xfs_ialloc_ag_select( agbp = NULL; if (!pag->pagi_inodeok) { - atomicIncWithWrap((int *)&mp->m_agirotor, agcount); + xfs_ialloc_next_ag(mp); goto unlock_nextag; } diff --git a/libxfs/xfs_inode.c b/libxfs/xfs_inode.c index adc4b557e..cf10b16a6 100644 --- a/libxfs/xfs_inode.c +++ b/libxfs/xfs_inode.c @@ -470,21 +470,16 @@ xfs_iformat_extents( ifp->if_bytes = size; ifp->if_real_bytes = real_size; if (size) { - xfs_validate_extents( - (xfs_bmbt_rec_t *)XFS_DFORK_PTR_ARCH(dip, whichfork, ARCH_CONVERT), - nex, 1, XFS_EXTFMT_INODE(ip)); - dp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR_ARCH(dip, whichfork, ARCH_CONVERT); + dp = (xfs_bmbt_rec_t *) + XFS_DFORK_PTR_ARCH(dip, whichfork, ARCH_CONVERT); + xfs_validate_extents(dp, nex, 1, XFS_EXTFMT_INODE(ip)); ep = ifp->if_u1.if_extents; -#if ARCH_CONVERT != ARCH_NOCONVERT for (i = 0; i < nex; i++, ep++, dp++) { ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), - ARCH_CONVERT); + ARCH_CONVERT); ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), - ARCH_CONVERT); + ARCH_CONVERT); } -#else - memcpy(ep, dp, size); -#endif xfs_bmap_trace_exlist("xfs_iformat_extents", ip, nex, whichfork); if (whichfork != XFS_DATA_FORK || @@ -1312,15 +1307,11 @@ xfs_iextents_copy( continue; } -#if ARCH_CONVERT != ARCH_NOCONVERT /* Translate to on disk format */ put_unaligned(INT_GET(ep->l0, ARCH_CONVERT), - (__uint64_t*)&dest_ep->l0); + (__uint64_t*)&dest_ep->l0); put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), - (__uint64_t*)&dest_ep->l1); -#else - *dest_ep = *ep; -#endif + (__uint64_t*)&dest_ep->l1); dest_ep++; ep++; copied++; diff --git a/libxfs/xfs_mount.c b/libxfs/xfs_mount.c index 372c39505..d2d9316ab 100644 --- a/libxfs/xfs_mount.c +++ b/libxfs/xfs_mount.c @@ -43,6 +43,7 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp) int i; mp->m_agfrotor = mp->m_agirotor = 0; + spinlock_init(&mp->m_agirotor_lock, "m_agirotor_lock"); mp->m_maxagi = mp->m_sb.sb_agcount; mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG; mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;