Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'gfs2-v5.18-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2

Pull gfs2 updates from Andreas Gruenbacher:

- Clean up the allocation of glocks that have an address space attached

- Quota locking fix and quota iomap conversion

- Fix the FITRIM error reporting

- Some list iterator cleanups

* tag 'gfs2-v5.18-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
gfs2: Convert function bh_get to use iomap
gfs2: use i_lock spin_lock for inode qadata
gfs2: Return more useful errors from gfs2_rgrp_send_discards()
gfs2: Use container_of() for gfs2_glock(aspace)
gfs2: Explain some direct I/O oddities
gfs2: replace 'found' with dedicated list iterator variable

+91 -66
+4
fs/gfs2/file.c
··· 840 840 pagefault_enable(); 841 841 if (ret <= 0 && ret != -EFAULT) 842 842 goto out_unlock; 843 + /* No increment (+=) because iomap_dio_rw returns a cumulative value. */ 843 844 if (ret > 0) 844 845 read = ret; 845 846 ··· 855 854 gfs2_glock_dq(gh); 856 855 out_uninit: 857 856 gfs2_holder_uninit(gh); 857 + /* User space doesn't expect partial success. */ 858 858 if (ret < 0) 859 859 return ret; 860 860 return read; ··· 908 906 if (ret != -EFAULT) 909 907 goto out_unlock; 910 908 } 909 + /* No increment (+=) because iomap_dio_rw returns a cumulative value. */ 911 910 if (ret > 0) 912 911 written = ret; 913 912 ··· 923 920 gfs2_glock_dq(gh); 924 921 out_uninit: 925 922 gfs2_holder_uninit(gh); 923 + /* User space doesn't expect partial success. */ 926 924 if (ret < 0) 927 925 return ret; 928 926 return written;
+19 -16
fs/gfs2/glock.c
··· 127 127 struct gfs2_glock *gl = container_of(rcu, struct gfs2_glock, gl_rcu); 128 128 129 129 kfree(gl->gl_lksb.sb_lvbptr); 130 - if (gl->gl_ops->go_flags & GLOF_ASPACE) 131 - kmem_cache_free(gfs2_glock_aspace_cachep, gl); 132 - else 130 + if (gl->gl_ops->go_flags & GLOF_ASPACE) { 131 + struct gfs2_glock_aspace *gla = 132 + container_of(gl, struct gfs2_glock_aspace, glock); 133 + kmem_cache_free(gfs2_glock_aspace_cachep, gla); 134 + } else 133 135 kmem_cache_free(gfs2_glock_cachep, gl); 134 136 } 135 137 ··· 1161 1159 .ln_sbd = sdp }; 1162 1160 struct gfs2_glock *gl, *tmp; 1163 1161 struct address_space *mapping; 1164 - struct kmem_cache *cachep; 1165 1162 int ret = 0; 1166 1163 1167 1164 gl = find_insert_glock(&name, NULL); ··· 1171 1170 if (!create) 1172 1171 return -ENOENT; 1173 1172 1174 - if (glops->go_flags & GLOF_ASPACE) 1175 - cachep = gfs2_glock_aspace_cachep; 1176 - else 1177 - cachep = gfs2_glock_cachep; 1178 - gl = kmem_cache_alloc(cachep, GFP_NOFS); 1179 - if (!gl) 1180 - return -ENOMEM; 1181 - 1173 + if (glops->go_flags & GLOF_ASPACE) { 1174 + struct gfs2_glock_aspace *gla = 1175 + kmem_cache_alloc(gfs2_glock_aspace_cachep, GFP_NOFS); 1176 + if (!gla) 1177 + return -ENOMEM; 1178 + gl = &gla->glock; 1179 + } else { 1180 + gl = kmem_cache_alloc(gfs2_glock_cachep, GFP_NOFS); 1181 + if (!gl) 1182 + return -ENOMEM; 1183 + } 1182 1184 memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb)); 1185 + gl->gl_ops = glops; 1183 1186 1184 1187 if (glops->go_flags & GLOF_LVB) { 1185 1188 gl->gl_lksb.sb_lvbptr = kzalloc(GDLM_LVB_SIZE, GFP_NOFS); 1186 1189 if (!gl->gl_lksb.sb_lvbptr) { 1187 - kmem_cache_free(cachep, gl); 1190 + gfs2_glock_dealloc(&gl->gl_rcu); 1188 1191 return -ENOMEM; 1189 1192 } 1190 1193 } ··· 1202 1197 gl->gl_state = LM_ST_UNLOCKED; 1203 1198 gl->gl_target = LM_ST_UNLOCKED; 1204 1199 gl->gl_demote_state = LM_ST_EXCLUSIVE; 1205 - gl->gl_ops = glops; 1206 1200 gl->gl_dstamp = 0; 1207 1201 preempt_disable(); 1208 1202 /* We use the global stats to estimate the initial per-glock stats */ ··· 1238 1234 *glp = tmp; 1239 1235 1240 1236 out_free: 1241 - kfree(gl->gl_lksb.sb_lvbptr); 1242 - kmem_cache_free(cachep, gl); 1237 + gfs2_glock_dealloc(&gl->gl_rcu); 1243 1238 if (atomic_dec_and_test(&sdp->sd_glock_disposal)) 1244 1239 wake_up(&sdp->sd_glock_wait); 1245 1240
+10 -2
fs/gfs2/glock.h
··· 138 138 const match_table_t *lm_tokens; 139 139 }; 140 140 141 + struct gfs2_glock_aspace { 142 + struct gfs2_glock glock; 143 + struct address_space mapping; 144 + }; 145 + 141 146 extern struct workqueue_struct *gfs2_delete_workqueue; 142 147 static inline struct gfs2_holder *gfs2_glock_is_locked_by_me(struct gfs2_glock *gl) 143 148 { ··· 184 179 185 180 static inline struct address_space *gfs2_glock2aspace(struct gfs2_glock *gl) 186 181 { 187 - if (gl->gl_ops->go_flags & GLOF_ASPACE) 188 - return (struct address_space *)(gl + 1); 182 + if (gl->gl_ops->go_flags & GLOF_ASPACE) { 183 + struct gfs2_glock_aspace *gla = 184 + container_of(gl, struct gfs2_glock_aspace, glock); 185 + return &gla->mapping; 186 + } 189 187 return NULL; 190 188 } 191 189
+4 -6
fs/gfs2/main.c
··· 62 62 63 63 static void gfs2_init_gl_aspace_once(void *foo) 64 64 { 65 - struct gfs2_glock *gl = foo; 66 - struct address_space *mapping = (struct address_space *)(gl + 1); 65 + struct gfs2_glock_aspace *gla = foo; 67 66 68 - gfs2_init_glock_once(gl); 69 - address_space_init_once(mapping); 67 + gfs2_init_glock_once(&gla->glock); 68 + address_space_init_once(&gla->mapping); 70 69 } 71 70 72 71 /** ··· 103 104 goto fail_cachep1; 104 105 105 106 gfs2_glock_aspace_cachep = kmem_cache_create("gfs2_glock(aspace)", 106 - sizeof(struct gfs2_glock) + 107 - sizeof(struct address_space), 107 + sizeof(struct gfs2_glock_aspace), 108 108 0, 0, gfs2_init_gl_aspace_once); 109 109 110 110 if (!gfs2_glock_aspace_cachep)
+5 -3
fs/gfs2/meta_io.h
··· 40 40 static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping) 41 41 { 42 42 struct inode *inode = mapping->host; 43 - if (mapping->a_ops == &gfs2_meta_aops) 44 - return (((struct gfs2_glock *)mapping) - 1)->gl_name.ln_sbd; 45 - else if (mapping->a_ops == &gfs2_rgrp_aops) 43 + if (mapping->a_ops == &gfs2_meta_aops) { 44 + struct gfs2_glock_aspace *gla = 45 + container_of(mapping, struct gfs2_glock_aspace, mapping); 46 + return gla->glock.gl_name.ln_sbd; 47 + } else if (mapping->a_ops == &gfs2_rgrp_aops) 46 48 return container_of(mapping, struct gfs2_sbd, sd_aspace); 47 49 else 48 50 return inode->i_sb->s_fs_info;
+37 -25
fs/gfs2/quota.c
··· 365 365 static int bh_get(struct gfs2_quota_data *qd) 366 366 { 367 367 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; 368 - struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); 368 + struct inode *inode = sdp->sd_qc_inode; 369 + struct gfs2_inode *ip = GFS2_I(inode); 369 370 unsigned int block, offset; 370 371 struct buffer_head *bh; 372 + struct iomap iomap = { }; 371 373 int error; 372 - struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 }; 373 374 374 375 mutex_lock(&sdp->sd_quota_mutex); 375 376 ··· 382 381 block = qd->qd_slot / sdp->sd_qc_per_block; 383 382 offset = qd->qd_slot % sdp->sd_qc_per_block; 384 383 385 - bh_map.b_size = BIT(ip->i_inode.i_blkbits); 386 - error = gfs2_block_map(&ip->i_inode, block, &bh_map, 0); 384 + error = gfs2_iomap_get(inode, 385 + (loff_t)block << inode->i_blkbits, 386 + i_blocksize(inode), &iomap); 387 387 if (error) 388 388 goto fail; 389 - error = gfs2_meta_read(ip->i_gl, bh_map.b_blocknr, DIO_WAIT, 0, &bh); 389 + error = -ENOENT; 390 + if (iomap.type != IOMAP_MAPPED) 391 + goto fail; 392 + 393 + error = gfs2_meta_read(ip->i_gl, iomap.addr >> inode->i_blkbits, 394 + DIO_WAIT, 0, &bh); 390 395 if (error) 391 396 goto fail; 392 397 error = -EIO; ··· 450 443 451 444 static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) 452 445 { 453 - struct gfs2_quota_data *qd = NULL; 446 + struct gfs2_quota_data *qd = NULL, *iter; 454 447 int error; 455 - int found = 0; 456 448 457 449 *qdp = NULL; 458 450 ··· 460 454 461 455 spin_lock(&qd_lock); 462 456 463 - list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) { 464 - found = qd_check_sync(sdp, qd, &sdp->sd_quota_sync_gen); 465 - if (found) 457 + list_for_each_entry(iter, &sdp->sd_quota_list, qd_list) { 458 + if (qd_check_sync(sdp, iter, &sdp->sd_quota_sync_gen)) { 459 + qd = iter; 466 460 break; 461 + } 467 462 } 468 - 469 - if (!found) 470 - qd = NULL; 471 463 472 464 spin_unlock(&qd_lock); 473 465 ··· 535 531 */ 536 532 int gfs2_qa_get(struct gfs2_inode *ip) 537 533 { 538 - int error = 0; 539 534 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 535 + struct inode *inode = &ip->i_inode; 540 536 541 537 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) 542 538 return 0; 543 539 544 - down_write(&ip->i_rw_mutex); 540 + spin_lock(&inode->i_lock); 545 541 if (ip->i_qadata == NULL) { 546 - ip->i_qadata = kmem_cache_zalloc(gfs2_qadata_cachep, GFP_NOFS); 547 - if (!ip->i_qadata) { 548 - error = -ENOMEM; 549 - goto out; 550 - } 542 + struct gfs2_qadata *tmp; 543 + 544 + spin_unlock(&inode->i_lock); 545 + tmp = kmem_cache_zalloc(gfs2_qadata_cachep, GFP_NOFS); 546 + if (!tmp) 547 + return -ENOMEM; 548 + 549 + spin_lock(&inode->i_lock); 550 + if (ip->i_qadata == NULL) 551 + ip->i_qadata = tmp; 552 + else 553 + kmem_cache_free(gfs2_qadata_cachep, tmp); 551 554 } 552 555 ip->i_qadata->qa_ref++; 553 - out: 554 - up_write(&ip->i_rw_mutex); 555 - return error; 556 + spin_unlock(&inode->i_lock); 557 + return 0; 556 558 } 557 559 558 560 void gfs2_qa_put(struct gfs2_inode *ip) 559 561 { 560 - down_write(&ip->i_rw_mutex); 562 + struct inode *inode = &ip->i_inode; 563 + 564 + spin_lock(&inode->i_lock); 561 565 if (ip->i_qadata && --ip->i_qadata->qa_ref == 0) { 562 566 kmem_cache_free(gfs2_qadata_cachep, ip->i_qadata); 563 567 ip->i_qadata = NULL; 564 568 } 565 - up_write(&ip->i_rw_mutex); 569 + spin_unlock(&inode->i_lock); 566 570 } 567 571 568 572 int gfs2_quota_hold(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
+10 -12
fs/gfs2/recovery.c
··· 55 55 int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where) 56 56 { 57 57 struct list_head *head = &jd->jd_revoke_list; 58 - struct gfs2_revoke_replay *rr; 59 - int found = 0; 58 + struct gfs2_revoke_replay *rr = NULL, *iter; 60 59 61 - list_for_each_entry(rr, head, rr_list) { 62 - if (rr->rr_blkno == blkno) { 63 - found = 1; 60 + list_for_each_entry(iter, head, rr_list) { 61 + if (iter->rr_blkno == blkno) { 62 + rr = iter; 64 63 break; 65 64 } 66 65 } 67 66 68 - if (found) { 67 + if (rr) { 69 68 rr->rr_where = where; 70 69 return 0; 71 70 } ··· 82 83 83 84 int gfs2_revoke_check(struct gfs2_jdesc *jd, u64 blkno, unsigned int where) 84 85 { 85 - struct gfs2_revoke_replay *rr; 86 + struct gfs2_revoke_replay *rr = NULL, *iter; 86 87 int wrap, a, b, revoke; 87 - int found = 0; 88 88 89 - list_for_each_entry(rr, &jd->jd_revoke_list, rr_list) { 90 - if (rr->rr_blkno == blkno) { 91 - found = 1; 89 + list_for_each_entry(iter, &jd->jd_revoke_list, rr_list) { 90 + if (iter->rr_blkno == blkno) { 91 + rr = iter; 92 92 break; 93 93 } 94 94 } 95 95 96 - if (!found) 96 + if (!rr) 97 97 return 0; 98 98 99 99 wrap = (rr->rr_where < jd->jd_replay_tail);
+2 -2
fs/gfs2/rgrp.c
··· 1315 1315 u64 blk; 1316 1316 sector_t start = 0; 1317 1317 sector_t nr_blks = 0; 1318 - int rv; 1318 + int rv = -EIO; 1319 1319 unsigned int x; 1320 1320 u32 trimmed = 0; 1321 1321 u8 diff; ··· 1371 1371 if (sdp->sd_args.ar_discard) 1372 1372 fs_warn(sdp, "error %d on discard request, turning discards off for this filesystem\n", rv); 1373 1373 sdp->sd_args.ar_discard = 0; 1374 - return -EIO; 1374 + return rv; 1375 1375 } 1376 1376 1377 1377 /**