Lines Matching refs:imap
51 #define IAGFREE_LOCK_INIT(imap) mutex_init(&imap->im_freelock) argument
52 #define IAGFREE_LOCK(imap) mutex_lock(&imap->im_freelock) argument
53 #define IAGFREE_UNLOCK(imap) mutex_unlock(&imap->im_freelock) argument
56 #define AG_LOCK_INIT(imap,index) mutex_init(&(imap->im_aglock[index])) argument
57 #define AG_LOCK(imap,agno) mutex_lock(&imap->im_aglock[agno]) argument
58 #define AG_UNLOCK(imap,agno) mutex_unlock(&imap->im_aglock[agno]) argument
73 static int diIAGRead(struct inomap * imap, int, struct metapage **);
96 struct inomap *imap; in diMount() local
105 imap = kmalloc(sizeof(struct inomap), GFP_KERNEL); in diMount()
106 if (imap == NULL) in diMount()
115 kfree(imap); in diMount()
121 imap->im_freeiag = le32_to_cpu(dinom_le->in_freeiag); in diMount()
122 imap->im_nextiag = le32_to_cpu(dinom_le->in_nextiag); in diMount()
123 atomic_set(&imap->im_numinos, le32_to_cpu(dinom_le->in_numinos)); in diMount()
124 atomic_set(&imap->im_numfree, le32_to_cpu(dinom_le->in_numfree)); in diMount()
125 imap->im_nbperiext = le32_to_cpu(dinom_le->in_nbperiext); in diMount()
126 imap->im_l2nbperiext = le32_to_cpu(dinom_le->in_l2nbperiext); in diMount()
128 imap->im_agctl[index].inofree = in diMount()
130 imap->im_agctl[index].extfree = in diMount()
132 imap->im_agctl[index].numinos = in diMount()
134 imap->im_agctl[index].numfree = in diMount()
145 IAGFREE_LOCK_INIT(imap); in diMount()
149 AG_LOCK_INIT(imap, index); in diMount()
155 imap->im_ipimap = ipimap; in diMount()
156 JFS_IP(ipimap)->i_imap = imap; in diMount()
178 struct inomap *imap = JFS_IP(ipimap)->i_imap; in diUnmount() local
195 kfree(imap); in diUnmount()
299 struct inomap *imap; in diRead() local
315 imap = JFS_IP(ipimap)->i_imap; in diRead()
316 rc = diIAGRead(imap, iagno, &mp); in diRead()
329 if ((lengthPXD(&iagp->inoext[extno]) != imap->im_nbperiext) || in diRead()
855 struct inomap *imap = JFS_IP(ipimap)->i_imap; in diFree() local
875 if (iagno >= imap->im_nextiag) { in diFree()
877 imap, 32, 0); in diFree()
879 (uint) inum, iagno, imap->im_nextiag); in diFree()
889 AG_LOCK(imap, agno); in diFree()
898 if ((rc = diIAGRead(imap, iagno, &mp))) { in diFree()
900 AG_UNLOCK(imap, agno); in diFree()
920 AG_UNLOCK(imap, agno); in diFree()
929 if (imap->im_agctl[agno].numfree > imap->im_agctl[agno].numinos) { in diFree()
932 AG_UNLOCK(imap, agno); in diFree()
941 imap->im_agctl[agno].numfree < 96 || in diFree()
942 (imap->im_agctl[agno].numfree < 288 && in diFree()
943 (((imap->im_agctl[agno].numfree * 100) / in diFree()
944 imap->im_agctl[agno].numinos) <= 25))) { in diFree()
955 if ((fwd = imap->im_agctl[agno].inofree) >= 0) { in diFree()
959 if ((rc = diIAGRead(imap, fwd, &))) { in diFree()
961 AG_UNLOCK(imap, agno); in diFree()
978 cpu_to_le32(imap->im_agctl[agno].inofree); in diFree()
980 imap->im_agctl[agno].inofree = iagno; in diFree()
1004 imap->im_agctl[agno].numfree += 1; in diFree()
1005 atomic_inc(&imap->im_numfree); in diFree()
1009 AG_UNLOCK(imap, agno); in diFree()
1039 if ((fwd = imap->im_agctl[agno].extfree) >= 0) { in diFree()
1040 if ((rc = diIAGRead(imap, fwd, &))) in diFree()
1057 if ((rc = diIAGRead(imap, fwd, &))) in diFree()
1063 if ((rc = diIAGRead(imap, back, &bmp))) in diFree()
1093 diIAGRead(imap, inofreefwd, &cmp))) in diFree()
1107 diIAGRead(imap, inofreeback, &dmp))) in diFree()
1134 cpu_to_le32(imap->im_agctl[agno].extfree); in diFree()
1136 imap->im_agctl[agno].extfree = iagno; in diFree()
1148 imap->im_agctl[agno].extfree = in diFree()
1153 IAGFREE_LOCK(imap); in diFree()
1154 iagp->iagfree = cpu_to_le32(imap->im_freeiag); in diFree()
1155 imap->im_freeiag = iagno; in diFree()
1156 IAGFREE_UNLOCK(imap); in diFree()
1170 imap->im_agctl[agno].inofree = in diFree()
1208 imap->im_agctl[agno].numfree -= (INOSPEREXT - 1); in diFree()
1209 imap->im_agctl[agno].numinos -= INOSPEREXT; in diFree()
1210 atomic_sub(INOSPEREXT - 1, &imap->im_numfree); in diFree()
1211 atomic_sub(INOSPEREXT, &imap->im_numinos); in diFree()
1268 AG_UNLOCK(imap, agno); in diFree()
1284 AG_UNLOCK(imap, agno); in diFree()
1332 struct inomap *imap; in diAlloc() local
1338 imap = JFS_IP(ipimap)->i_imap; in diAlloc()
1347 AG_LOCK(imap, agno); in diAlloc()
1373 AG_LOCK(imap, agno); in diAlloc()
1385 AG_LOCK(imap, agno); in diAlloc()
1392 if ((rc = diIAGRead(imap, iagno, &mp))) { in diAlloc()
1394 AG_UNLOCK(imap, agno); in diAlloc()
1403 addext = (imap->im_agctl[agno].numfree < 32 && iagp->nfreeexts); in diAlloc()
1430 rc = diAllocBit(imap, iagp, ino); in diAlloc()
1446 AG_UNLOCK(imap, agno); in diAlloc()
1502 AG_UNLOCK(imap, agno); in diAlloc()
1513 rc = diAllocBit(imap, iagp, ino); in diAlloc()
1529 AG_UNLOCK(imap, agno); in diAlloc()
1547 if ((rc = diNewExt(imap, iagp, extno))) { in diAlloc()
1569 AG_UNLOCK(imap, agno); in diAlloc()
1590 rc = diAllocAG(imap, agno, dir, ip); in diAlloc()
1592 AG_UNLOCK(imap, agno); in diAlloc()
1600 return (diAllocAny(imap, agno, dir, ip)); in diAlloc()
1634 diAllocAG(struct inomap * imap, int agno, bool dir, struct inode *ip) in diAllocAG() argument
1641 numfree = imap->im_agctl[agno].numfree; in diAllocAG()
1642 numinos = imap->im_agctl[agno].numinos; in diAllocAG()
1669 if ((rc = diAllocExt(imap, agno, ip)) != -ENOSPC) in diAllocAG()
1676 return (diAllocIno(imap, agno, ip)); in diAllocAG()
1704 diAllocAny(struct inomap * imap, int agno, bool dir, struct inode *ip) in diAllocAny() argument
1707 int maxag = JFS_SBI(imap->im_ipimap->i_sb)->bmap->db_maxag; in diAllocAny()
1714 AG_LOCK(imap, ag); in diAllocAny()
1716 rc = diAllocAG(imap, ag, dir, ip); in diAllocAny()
1718 AG_UNLOCK(imap, ag); in diAllocAny()
1727 AG_LOCK(imap, ag); in diAllocAny()
1729 rc = diAllocAG(imap, ag, dir, ip); in diAllocAny()
1731 AG_UNLOCK(imap, ag); in diAllocAny()
1768 static int diAllocIno(struct inomap * imap, int agno, struct inode *ip) in diAllocIno() argument
1776 if ((iagno = imap->im_agctl[agno].inofree) < 0) in diAllocIno()
1780 IREAD_LOCK(imap->im_ipimap, RDWRLOCK_IMAP); in diAllocIno()
1784 if ((rc = diIAGRead(imap, iagno, &mp))) { in diAllocIno()
1785 IREAD_UNLOCK(imap->im_ipimap); in diAllocIno()
1794 IREAD_UNLOCK(imap->im_ipimap); in diAllocIno()
1805 IREAD_UNLOCK(imap->im_ipimap); in diAllocIno()
1821 IREAD_UNLOCK(imap->im_ipimap); in diAllocIno()
1832 IREAD_UNLOCK(imap->im_ipimap); in diAllocIno()
1844 rc = diAllocBit(imap, iagp, ino); in diAllocIno()
1845 IREAD_UNLOCK(imap->im_ipimap); in diAllocIno()
1892 static int diAllocExt(struct inomap * imap, int agno, struct inode *ip) in diAllocExt() argument
1901 if ((iagno = imap->im_agctl[agno].extfree) < 0) { in diAllocExt()
1905 if ((rc = diNewIAG(imap, &iagno, agno, &mp))) { in diAllocExt()
1913 cpu_to_le64(AGTOBLK(agno, imap->im_ipimap)); in diAllocExt()
1917 IREAD_LOCK(imap->im_ipimap, RDWRLOCK_IMAP); in diAllocExt()
1918 if ((rc = diIAGRead(imap, iagno, &mp))) { in diAllocExt()
1919 IREAD_UNLOCK(imap->im_ipimap); in diAllocExt()
1931 IREAD_UNLOCK(imap->im_ipimap); in diAllocExt()
1944 IREAD_UNLOCK(imap->im_ipimap); in diAllocExt()
1952 rc = diNewExt(imap, iagp, extno); in diAllocExt()
1953 IREAD_UNLOCK(imap->im_ipimap); in diAllocExt()
1960 IAGFREE_LOCK(imap); in diAllocExt()
1961 iagp->iagfree = cpu_to_le32(imap->im_freeiag); in diAllocExt()
1962 imap->im_freeiag = iagno; in diAllocExt()
1963 IAGFREE_UNLOCK(imap); in diAllocExt()
2009 static int diAllocBit(struct inomap * imap, struct iag * iagp, int ino) in diAllocBit() argument
2024 diIAGRead(imap, le32_to_cpu(iagp->inofreefwd), in diAllocBit()
2032 diIAGRead(imap, in diAllocBit()
2046 agno = BLKTOAG(le64_to_cpu(iagp->agstart), JFS_SBI(imap->im_ipimap->i_sb)); in diAllocBit()
2064 jfs_error(imap->im_ipimap->i_sb, "iag inconsistent\n"); in diAllocBit()
2095 imap->im_agctl[agno].inofree = in diAllocBit()
2105 imap->im_agctl[agno].numfree -= 1; in diAllocBit()
2106 atomic_dec(&imap->im_numfree); in diAllocBit()
2155 static int diNewExt(struct inomap * imap, struct iag * iagp, int extno) in diNewExt() argument
2171 jfs_error(imap->im_ipimap->i_sb, "no free extents\n"); in diNewExt()
2177 ipimap = imap->im_ipimap; in diNewExt()
2197 if ((rc = diIAGRead(imap, fwd, &))) in diNewExt()
2203 if ((rc = diIAGRead(imap, back, &bmp))) in diNewExt()
2216 if ((fwd = imap->im_agctl[agno].extfree) >= 0) { in diNewExt()
2217 if ((rc = diIAGRead(imap, fwd, &))) in diNewExt()
2232 freei = imap->im_agctl[agno].inofree; in diNewExt()
2240 if ((rc = diIAGRead(imap, freei, &cmp))) in diNewExt()
2245 jfs_error(imap->im_ipimap->i_sb, in diNewExt()
2261 if ((rc = dbAlloc(ipimap, hint, (s64) imap->im_nbperiext, &blkno))) in diNewExt()
2272 for (i = 0; i < imap->im_nbperiext; i += sbi->nbperpage) { in diNewExt()
2292 PXDlength(&(dp->di_ixpxd), imap->im_nbperiext); in diNewExt()
2307 imap->im_agctl[agno].extfree = in diNewExt()
2321 imap->im_agctl[agno].extfree = iagno; in diNewExt()
2333 cpu_to_le32(imap->im_agctl[agno].inofree); in diNewExt()
2335 imap->im_agctl[agno].inofree = iagno; in diNewExt()
2339 PXDlength(&iagp->inoext[extno], imap->im_nbperiext); in diNewExt()
2366 imap->im_agctl[agno].numfree += (INOSPEREXT - 1); in diNewExt()
2367 imap->im_agctl[agno].numinos += INOSPEREXT; in diNewExt()
2371 atomic_add(INOSPEREXT - 1, &imap->im_numfree); in diNewExt()
2372 atomic_add(INOSPEREXT, &imap->im_numinos); in diNewExt()
2440 diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp) in diNewIAG() argument
2455 ipimap = imap->im_ipimap; in diNewIAG()
2460 IAGFREE_LOCK(imap); in diNewIAG()
2465 if (imap->im_freeiag >= 0) { in diNewIAG()
2467 iagno = imap->im_freeiag; in diNewIAG()
2479 if (ipimap->i_size >> L2PSIZE != imap->im_nextiag + 1) { in diNewIAG()
2481 IAGFREE_UNLOCK(imap); in diNewIAG()
2482 jfs_error(imap->im_ipimap->i_sb, in diNewIAG()
2489 iagno = imap->im_nextiag; in diNewIAG()
2600 imap->im_nextiag += 1; in diNewIAG()
2605 imap->im_freeiag = iagno; in diNewIAG()
2620 if ((rc = diIAGRead(imap, iagno, &mp))) { in diNewIAG()
2628 imap->im_freeiag = le32_to_cpu(iagp->iagfree); in diNewIAG()
2637 IAGFREE_UNLOCK(imap); in diNewIAG()
2663 static int diIAGRead(struct inomap * imap, int iagno, struct metapage ** mpp) in diIAGRead() argument
2665 struct inode *ipimap = imap->im_ipimap; in diIAGRead()
2732 struct inomap *imap; in diUpdatePMap() local
2738 imap = JFS_IP(ipimap)->i_imap; in diUpdatePMap()
2742 if (iagno >= imap->im_nextiag) { in diUpdatePMap()
2748 rc = diIAGRead(imap, iagno, &mp); in diUpdatePMap()
2850 struct inomap *imap = JFS_IP(ipimap)->i_imap; in diExtendFS() local
2859 imap->im_nextiag, atomic_read(&imap->im_numinos), in diExtendFS()
2860 atomic_read(&imap->im_numfree)); in diExtendFS()
2872 imap->im_agctl[i].inofree = -1; in diExtendFS()
2873 imap->im_agctl[i].extfree = -1; in diExtendFS()
2874 imap->im_agctl[i].numinos = 0; /* number of backed inodes */ in diExtendFS()
2875 imap->im_agctl[i].numfree = 0; /* number of free backed inodes */ in diExtendFS()
2883 for (i = 0; i < imap->im_nextiag; i++) { in diExtendFS()
2884 if ((rc = diIAGRead(imap, i, &bp))) { in diExtendFS()
2910 imap->im_agctl[n].numinos += numinos; in diExtendFS()
2916 if ((head = imap->im_agctl[n].inofree) == -1) { in diExtendFS()
2920 if ((rc = diIAGRead(imap, head, &hbp))) { in diExtendFS()
2931 imap->im_agctl[n].inofree = in diExtendFS()
2935 imap->im_agctl[n].numfree += in diExtendFS()
2942 if ((head = imap->im_agctl[n].extfree) == -1) { in diExtendFS()
2946 if ((rc = diIAGRead(imap, head, &hbp))) { in diExtendFS()
2957 imap->im_agctl[n].extfree = in diExtendFS()
2965 if (xnuminos != atomic_read(&imap->im_numinos) || in diExtendFS()
2966 xnumfree != atomic_read(&imap->im_numfree)) { in diExtendFS()