4343 * the logging system and therefore never have a log item.
4444 */
4545
46- /*
47- * Each contiguous block has a header, so it is not just a simple attribute
48- * length to FSB conversion.
49- */
50- int
46+ /* How many bytes can be stored in a remote value buffer? */
47+ inline unsigned int
48+ xfs_attr3_rmt_buf_space (
49+ struct xfs_mount * mp )
50+ {
51+ unsigned int blocksize = mp -> m_attr_geo -> blksize ;
52+
53+ if (xfs_has_crc (mp ))
54+ return blocksize - sizeof (struct xfs_attr3_rmt_hdr );
55+
56+ return blocksize ;
57+ }
58+
59+ /* Compute number of fsblocks needed to store a remote attr value */
60+ unsigned int
5161xfs_attr3_rmt_blocks (
52- struct xfs_mount * mp ,
53- int attrlen )
62+ struct xfs_mount * mp ,
63+ unsigned int attrlen )
5464{
55- if (xfs_has_crc (mp )) {
56- int buflen = XFS_ATTR3_RMT_BUF_SPACE (mp , mp -> m_sb .sb_blocksize );
57- return (attrlen + buflen - 1 ) / buflen ;
58- }
65+ /*
66+ * Each contiguous block has a header, so it is not just a simple
67+ * attribute length to FSB conversion.
68+ */
69+ if (xfs_has_crc (mp ))
70+ return howmany (attrlen , xfs_attr3_rmt_buf_space (mp ));
71+
5972 return XFS_B_TO_FSB (mp , attrlen );
6073}
6174
@@ -92,7 +105,6 @@ xfs_attr3_rmt_verify(
92105 struct xfs_mount * mp ,
93106 struct xfs_buf * bp ,
94107 void * ptr ,
95- int fsbsize ,
96108 xfs_daddr_t bno )
97109{
98110 struct xfs_attr3_rmt_hdr * rmt = ptr ;
@@ -103,7 +115,7 @@ xfs_attr3_rmt_verify(
103115 return __this_address ;
104116 if (be64_to_cpu (rmt -> rm_blkno ) != bno )
105117 return __this_address ;
106- if (be32_to_cpu (rmt -> rm_bytes ) > fsbsize - sizeof (* rmt ))
118+ if (be32_to_cpu (rmt -> rm_bytes ) > mp -> m_attr_geo -> blksize - sizeof (* rmt ))
107119 return __this_address ;
108120 if (be32_to_cpu (rmt -> rm_offset ) +
109121 be32_to_cpu (rmt -> rm_bytes ) > XFS_XATTR_SIZE_MAX )
@@ -122,9 +134,9 @@ __xfs_attr3_rmt_read_verify(
122134{
123135 struct xfs_mount * mp = bp -> b_mount ;
124136 char * ptr ;
125- int len ;
137+ unsigned int len ;
126138 xfs_daddr_t bno ;
127- int blksize = mp -> m_attr_geo -> blksize ;
139+ unsigned int blksize = mp -> m_attr_geo -> blksize ;
128140
129141 /* no verification of non-crc buffers */
130142 if (!xfs_has_crc (mp ))
@@ -141,7 +153,7 @@ __xfs_attr3_rmt_read_verify(
141153 * failaddr = __this_address ;
142154 return - EFSBADCRC ;
143155 }
144- * failaddr = xfs_attr3_rmt_verify (mp , bp , ptr , blksize , bno );
156+ * failaddr = xfs_attr3_rmt_verify (mp , bp , ptr , bno );
145157 if (* failaddr )
146158 return - EFSCORRUPTED ;
147159 len -= blksize ;
@@ -186,7 +198,7 @@ xfs_attr3_rmt_write_verify(
186198{
187199 struct xfs_mount * mp = bp -> b_mount ;
188200 xfs_failaddr_t fa ;
189- int blksize = mp -> m_attr_geo -> blksize ;
201+ unsigned int blksize = mp -> m_attr_geo -> blksize ;
190202 char * ptr ;
191203 int len ;
192204 xfs_daddr_t bno ;
@@ -203,7 +215,7 @@ xfs_attr3_rmt_write_verify(
203215 while (len > 0 ) {
204216 struct xfs_attr3_rmt_hdr * rmt = (struct xfs_attr3_rmt_hdr * )ptr ;
205217
206- fa = xfs_attr3_rmt_verify (mp , bp , ptr , blksize , bno );
218+ fa = xfs_attr3_rmt_verify (mp , bp , ptr , bno );
207219 if (fa ) {
208220 xfs_verifier_error (bp , - EFSCORRUPTED , fa );
209221 return ;
@@ -281,20 +293,20 @@ xfs_attr_rmtval_copyout(
281293 struct xfs_buf * bp ,
282294 struct xfs_inode * dp ,
283295 xfs_ino_t owner ,
284- int * offset ,
285- int * valuelen ,
296+ unsigned int * offset ,
297+ unsigned int * valuelen ,
286298 uint8_t * * dst )
287299{
288300 char * src = bp -> b_addr ;
289301 xfs_daddr_t bno = xfs_buf_daddr (bp );
290- int len = BBTOB (bp -> b_length );
291- int blksize = mp -> m_attr_geo -> blksize ;
302+ unsigned int len = BBTOB (bp -> b_length );
303+ unsigned int blksize = mp -> m_attr_geo -> blksize ;
292304
293305 ASSERT (len >= blksize );
294306
295307 while (len > 0 && * valuelen > 0 ) {
296- int hdr_size = 0 ;
297- int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE (mp , blksize );
308+ unsigned int hdr_size = 0 ;
309+ unsigned int byte_cnt = xfs_attr3_rmt_buf_space (mp );
298310
299311 byte_cnt = min (* valuelen , byte_cnt );
300312
@@ -330,20 +342,20 @@ xfs_attr_rmtval_copyin(
330342 struct xfs_mount * mp ,
331343 struct xfs_buf * bp ,
332344 xfs_ino_t ino ,
333- int * offset ,
334- int * valuelen ,
345+ unsigned int * offset ,
346+ unsigned int * valuelen ,
335347 uint8_t * * src )
336348{
337349 char * dst = bp -> b_addr ;
338350 xfs_daddr_t bno = xfs_buf_daddr (bp );
339- int len = BBTOB (bp -> b_length );
340- int blksize = mp -> m_attr_geo -> blksize ;
351+ unsigned int len = BBTOB (bp -> b_length );
352+ unsigned int blksize = mp -> m_attr_geo -> blksize ;
341353
342354 ASSERT (len >= blksize );
343355
344356 while (len > 0 && * valuelen > 0 ) {
345- int hdr_size ;
346- int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE (mp , blksize );
357+ unsigned int hdr_size ;
358+ unsigned int byte_cnt = xfs_attr3_rmt_buf_space (mp );
347359
348360 byte_cnt = min (* valuelen , byte_cnt );
349361 hdr_size = xfs_attr3_rmt_hdr_set (mp , dst , ino , * offset ,
@@ -389,12 +401,12 @@ xfs_attr_rmtval_get(
389401 struct xfs_buf * bp ;
390402 xfs_dablk_t lblkno = args -> rmtblkno ;
391403 uint8_t * dst = args -> value ;
392- int valuelen ;
404+ unsigned int valuelen ;
393405 int nmap ;
394406 int error ;
395- int blkcnt = args -> rmtblkcnt ;
407+ unsigned int blkcnt = args -> rmtblkcnt ;
396408 int i ;
397- int offset = 0 ;
409+ unsigned int offset = 0 ;
398410
399411 trace_xfs_attr_rmtval_get (args );
400412
@@ -452,7 +464,7 @@ xfs_attr_rmt_find_hole(
452464 struct xfs_inode * dp = args -> dp ;
453465 struct xfs_mount * mp = dp -> i_mount ;
454466 int error ;
455- int blkcnt ;
467+ unsigned int blkcnt ;
456468 xfs_fileoff_t lfileoff = 0 ;
457469
458470 /*
@@ -481,11 +493,11 @@ xfs_attr_rmtval_set_value(
481493 struct xfs_bmbt_irec map ;
482494 xfs_dablk_t lblkno ;
483495 uint8_t * src = args -> value ;
484- int blkcnt ;
485- int valuelen ;
496+ unsigned int blkcnt ;
497+ unsigned int valuelen ;
486498 int nmap ;
487499 int error ;
488- int offset = 0 ;
500+ unsigned int offset = 0 ;
489501
490502 /*
491503 * Roll through the "value", copying the attribute value to the
@@ -644,7 +656,7 @@ xfs_attr_rmtval_invalidate(
644656 struct xfs_da_args * args )
645657{
646658 xfs_dablk_t lblkno ;
647- int blkcnt ;
659+ unsigned int blkcnt ;
648660 int error ;
649661
650662 /*
0 commit comments