equal
deleted
inserted
replaced
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 /* |
21 /* |
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
23 * Use is subject to license terms. |
23 * Use is subject to license terms. |
24 */ |
24 */ |
25 |
25 |
26 /* |
26 /* |
27 * This file contains the code to implement file range locking in |
27 * This file contains the code to implement file range locking in |
110 for (;;) { |
110 for (;;) { |
111 /* |
111 /* |
112 * Range locking is also used by zvol and uses a |
112 * Range locking is also used by zvol and uses a |
113 * dummied up znode. However, for zvol, we don't need to |
113 * dummied up znode. However, for zvol, we don't need to |
114 * append or grow blocksize, and besides we don't have |
114 * append or grow blocksize, and besides we don't have |
115 * a z_phys or z_zfsvfs - so skip that processing. |
115 * a "sa" data or z_zfsvfs - so skip that processing. |
116 * |
116 * |
117 * Yes, this is ugly, and would be solved by not handling |
117 * Yes, this is ugly, and would be solved by not handling |
118 * grow or append in range lock code. If that was done then |
118 * grow or append in range lock code. If that was done then |
119 * we could make the range locking code generically available |
119 * we could make the range locking code generically available |
120 * to other non-zfs consumers. |
120 * to other non-zfs consumers. |
123 /* |
123 /* |
124 * If in append mode pick up the current end of file. |
124 * If in append mode pick up the current end of file. |
125 * This is done under z_range_lock to avoid races. |
125 * This is done under z_range_lock to avoid races. |
126 */ |
126 */ |
127 if (new->r_type == RL_APPEND) |
127 if (new->r_type == RL_APPEND) |
128 new->r_off = zp->z_phys->zp_size; |
128 new->r_off = zp->z_size; |
129 |
129 |
130 /* |
130 /* |
131 * If we need to grow the block size then grab the whole |
131 * If we need to grow the block size then grab the whole |
132 * file range. This is also done under z_range_lock to |
132 * file range. This is also done under z_range_lock to |
133 * avoid races. |
133 * avoid races. |
134 */ |
134 */ |
135 end_size = MAX(zp->z_phys->zp_size, new->r_off + len); |
135 end_size = MAX(zp->z_size, new->r_off + len); |
136 if (end_size > zp->z_blksz && (!ISP2(zp->z_blksz) || |
136 if (end_size > zp->z_blksz && (!ISP2(zp->z_blksz) || |
137 zp->z_blksz < zp->z_zfsvfs->z_max_blksz)) { |
137 zp->z_blksz < zp->z_zfsvfs->z_max_blksz)) { |
138 new->r_off = 0; |
138 new->r_off = 0; |
139 new->r_len = UINT64_MAX; |
139 new->r_len = UINT64_MAX; |
140 } |
140 } |