aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iomap.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-04-28 08:28:56 -0400
committerAlex Elder <aelder@sgi.com>2010-05-19 10:58:17 -0400
commit207d041602cead1c1a16288f6225aea9da1f5bc4 (patch)
treead6149735c8bc0c5d112e301e6e17dac6280dcb6 /fs/xfs/xfs_iomap.c
parente513182d4d7ec8f1870ae368c549ef2838e2c105 (diff)
xfs: kill struct xfs_iomap
Now that struct xfs_iomap contains exactly the same units as struct xfs_bmbt_irec we can just use the latter directly in the aops code. Replace the missing IOMAP_NEW flag with a new boolean output parameter to xfs_iomap. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r--fs/xfs/xfs_iomap.c82
1 files changed, 28 insertions, 54 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index fbe5d32f9ef5..7545dcdaa8aa 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -55,46 +55,25 @@
55#define XFS_STRAT_WRITE_IMAPS 2 55#define XFS_STRAT_WRITE_IMAPS 2
56#define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP 56#define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP
57 57
58STATIC void
59xfs_imap_to_bmap(
60 xfs_inode_t *ip,
61 xfs_off_t offset,
62 xfs_bmbt_irec_t *imap,
63 xfs_iomap_t *iomapp,
64 int imaps, /* Number of imap entries */
65 int flags)
66{
67 iomapp->iomap_offset = imap->br_startoff;
68 iomapp->iomap_bsize = imap->br_blockcount;
69 iomapp->iomap_flags = flags;
70 iomapp->iomap_bn = imap->br_startblock;
71
72 if (imap->br_startblock != HOLESTARTBLOCK &&
73 imap->br_startblock != DELAYSTARTBLOCK &&
74 ISUNWRITTEN(imap))
75 iomapp->iomap_flags |= IOMAP_UNWRITTEN;
76}
77
78int 58int
79xfs_iomap( 59xfs_iomap(
80 xfs_inode_t *ip, 60 struct xfs_inode *ip,
81 xfs_off_t offset, 61 xfs_off_t offset,
82 ssize_t count, 62 ssize_t count,
83 int flags, 63 int flags,
84 xfs_iomap_t *iomapp, 64 struct xfs_bmbt_irec *imap,
85 int *niomaps) 65 int *nimaps,
66 int *new)
86{ 67{
87 xfs_mount_t *mp = ip->i_mount; 68 struct xfs_mount *mp = ip->i_mount;
88 xfs_fileoff_t offset_fsb, end_fsb; 69 xfs_fileoff_t offset_fsb, end_fsb;
89 int error = 0; 70 int error = 0;
90 int lockmode = 0; 71 int lockmode = 0;
91 xfs_bmbt_irec_t imap; 72 int bmapi_flags = 0;
92 int nimaps = 1;
93 int bmapi_flags = 0;
94 int iomap_flags = 0;
95 73
96 ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); 74 ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
97 ASSERT(niomaps && *niomaps == 1); 75
76 *new = 0;
98 77
99 if (XFS_FORCED_SHUTDOWN(mp)) 78 if (XFS_FORCED_SHUTDOWN(mp))
100 return XFS_ERROR(EIO); 79 return XFS_ERROR(EIO);
@@ -136,8 +115,8 @@ xfs_iomap(
136 115
137 error = xfs_bmapi(NULL, ip, offset_fsb, 116 error = xfs_bmapi(NULL, ip, offset_fsb,
138 (xfs_filblks_t)(end_fsb - offset_fsb), 117 (xfs_filblks_t)(end_fsb - offset_fsb),
139 bmapi_flags, NULL, 0, &imap, 118 bmapi_flags, NULL, 0, imap,
140 &nimaps, NULL, NULL); 119 nimaps, NULL, NULL);
141 120
142 if (error) 121 if (error)
143 goto out; 122 goto out;
@@ -145,45 +124,41 @@ xfs_iomap(
145 switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) { 124 switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
146 case BMAPI_WRITE: 125 case BMAPI_WRITE:
147 /* If we found an extent, return it */ 126 /* If we found an extent, return it */
148 if (nimaps && 127 if (*nimaps &&
149 (imap.br_startblock != HOLESTARTBLOCK) && 128 (imap->br_startblock != HOLESTARTBLOCK) &&
150 (imap.br_startblock != DELAYSTARTBLOCK)) { 129 (imap->br_startblock != DELAYSTARTBLOCK)) {
151 trace_xfs_iomap_found(ip, offset, count, flags, &imap); 130 trace_xfs_iomap_found(ip, offset, count, flags, imap);
152 break; 131 break;
153 } 132 }
154 133
155 if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) { 134 if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) {
156 error = xfs_iomap_write_direct(ip, offset, count, flags, 135 error = xfs_iomap_write_direct(ip, offset, count, flags,
157 &imap, &nimaps, nimaps); 136 imap, nimaps, *nimaps);
158 } else { 137 } else {
159 error = xfs_iomap_write_delay(ip, offset, count, flags, 138 error = xfs_iomap_write_delay(ip, offset, count, flags,
160 &imap, &nimaps); 139 imap, nimaps);
161 } 140 }
162 if (!error) { 141 if (!error) {
163 trace_xfs_iomap_alloc(ip, offset, count, flags, &imap); 142 trace_xfs_iomap_alloc(ip, offset, count, flags, imap);
164 } 143 }
165 iomap_flags = IOMAP_NEW; 144 *new = 1;
166 break; 145 break;
167 case BMAPI_ALLOCATE: 146 case BMAPI_ALLOCATE:
168 /* If we found an extent, return it */ 147 /* If we found an extent, return it */
169 xfs_iunlock(ip, lockmode); 148 xfs_iunlock(ip, lockmode);
170 lockmode = 0; 149 lockmode = 0;
171 150
172 if (nimaps && !isnullstartblock(imap.br_startblock)) { 151 if (*nimaps && !isnullstartblock(imap->br_startblock)) {
173 trace_xfs_iomap_found(ip, offset, count, flags, &imap); 152 trace_xfs_iomap_found(ip, offset, count, flags, imap);
174 break; 153 break;
175 } 154 }
176 155
177 error = xfs_iomap_write_allocate(ip, offset, count, 156 error = xfs_iomap_write_allocate(ip, offset, count,
178 &imap, &nimaps); 157 imap, nimaps);
179 break; 158 break;
180 } 159 }
181 160
182 ASSERT(nimaps <= 1); 161 ASSERT(*nimaps <= 1);
183
184 if (nimaps)
185 xfs_imap_to_bmap(ip, offset, &imap, iomapp, nimaps, iomap_flags);
186 *niomaps = nimaps;
187 162
188out: 163out:
189 if (lockmode) 164 if (lockmode)
@@ -191,7 +166,6 @@ out:
191 return XFS_ERROR(error); 166 return XFS_ERROR(error);
192} 167}
193 168
194
195STATIC int 169STATIC int
196xfs_iomap_eof_align_last_fsb( 170xfs_iomap_eof_align_last_fsb(
197 xfs_mount_t *mp, 171 xfs_mount_t *mp,