gfs2: eliminate rs_inum and reduce the size of gfs2 inodes
PATCH 1/1 gfs2: eliminate rs_inum and reduce the size of gfs2 inodes
In reply to a message not in the archiveHi,
Before this patch, block reservations kept track of the inode number. At one point, that was a valid thing to do. However, since we made the reservation a part of the inode (rather than a pointer to a separate allocated object) the reservation can determine the inode number by using container_of. This saves us a little memory in our inode.
--- fs/gfs2/incore.h | 1 - fs/gfs2/rgrp.c | 5 +++-- fs/gfs2/trace_gfs2.h | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-)
fs/gfs2/incore.h +0 -1
@@ -295,7 +295,6 @@ struct gfs2_blkreserv {struct rb_node rs_node;/* link to other block reservations */ struct gfs2_rbm rs_rbm;/* Start of reservation */ u32 rs_free;/* how many blocks are still free */ -u64 rs_inum;/* Inode number for reservation */ };/*
fs/gfs2/rgrp.c +3 -2
@@ -607,8 +607,10 @@ int gfs2_rsqa_alloc(struct gfs2_inode *ip)static void dump_rs (struct seq_file *seq,const struct gfs2_blkreserv *rs) { + struct gfs2_inode *ip = container_of(rs, struct gfs2_inode, i_res); +gfs2_print_dbg (seq," B: n:%llu s:%llu b:%u f:%u\n" , - (unsigned long long )rs->rs_inum, + (unsigned long long )ip->i_no_addr, (unsigned long long )gfs2_rbm_to_block (&rs->rs_rbm), rs->rs_rbm.offset, rs->rs_free); }
@@ -1528,7 +1530,6 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,if (ret ==0 ) { rs->rs_rbm = rbm; rs->rs_free = extlen; - rs->rs_inum = ip->i_no_addr;rs_insert (ip); }else {if (goal == rgd->rd_last_alloc + rgd->rd_data0)
fs/gfs2/trace_gfs2.h +2 -1
@@ -606,7 +606,8 @@ TRACE_EVENT(gfs2_rs, __entry->rd_addr = rs->rs_rbm.rgd->rd_addr; __entry->rd_free_clone = rs->rs_rbm.rgd->rd_free_clone; __entry->rd_reserved = rs->rs_rbm.rgd->rd_reserved; - __entry->inum = rs->rs_inum; + __entry->inum = container_of(rs, struct gfs2_inode, + i_res)->i_no_addr; __entry->start =gfs2_rbm_to_block (&rs->rs_rbm); __entry->free = rs->rs_free; __entry->func = func;
PATCH 1/1 gfs2: eliminate rs_inum and reduce the size of gfs2 inodes
Hi,
Yes, that seems like a good plan
Steve.
Quoted 67 lines · Bob Peterson
Hi,
Before this patch, block reservations kept track of the inode number. At one point, that was a valid thing to do. However, since we made the reservation a part of the inode (rather than a pointer to a separate allocated object) the reservation can determine the inode number by using
container_of. This saves us a little memory in our inode.Signed-off-by Bob Peterson <[email protected]>--- fs/gfs2/incore.h | 1 - fs/gfs2/rgrp.c | 5 +++-- fs/gfs2/trace_gfs2.h | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-)fs/gfs2/incore.h +0
-1@@ -295,7 +295,6 @@ struct gfs2_blkreserv {struct rb_node rs_node;/* link to other block reservations */ struct gfs2_rbm rs_rbm;/* Start of reservation */ u32 rs_free;/* how many blocks are still free */ -u64 rs_inum;/* Inode number for reservation */ };/* fs/gfs2/rgrp.c +3
-2@@ -607,8 +607,10 @@ int gfs2_rsqa_alloc(struct gfs2_inode *ip)static void dump_rs (struct seq_file *seq,const struct gfs2_blkreserv *rs) { + struct gfs2_inode *ip = container_of(rs, struct gfs2_inode, i_res); +gfs2_print_dbg (seq," B: n:%llu s:%llu b:%u f:%u\n" , - (unsigned long long )rs->rs_inum, + (unsigned long long )ip->i_no_addr, (unsigned long long )gfs2_rbm_to_block (&rs->rs_rbm), rs->rs_rbm.offset, rs->rs_free); }@@ -1528,7 +1530,6 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,if (ret ==0 ) { rs->rs_rbm = rbm; rs->rs_free = extlen; - rs->rs_inum = ip->i_no_addr;rs_insert (ip); }else {if (goal == rgd->rd_last_alloc + rgd->rd_data0)fs/gfs2/trace_gfs2.h +2
-1@@ -606,7 +606,8 @@ TRACE_EVENT(gfs2_rs, __entry->rd_addr = rs->rs_rbm.rgd->rd_addr; __entry->rd_free_clone = rs->rs_rbm.rgd->rd_free_clone; __entry->rd_reserved = rs->rs_rbm.rgd->rd_reserved; - __entry->inum = rs->rs_inum; + __entry->inum = container_of(rs, struct gfs2_inode, + i_res)->i_no_addr; __entry->start =gfs2_rbm_to_block (&rs->rs_rbm); __entry->free = rs->rs_free; __entry->func = func;
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: eliminate rs_inum and reduce the size of gfs2 inodes
In reply to Bob PetersonQuoted 58 lines · Bob Peterson
Hi,
Before this patch, block reservations kept track of the inode number. At one point, that was a valid thing to do. However, since we made the reservation a part of the inode (rather than a pointer to a separate allocated object) the reservation can determine the inode number by using
container_of. This saves us a little memory in our inode.Signed-off-by Bob Peterson <[email protected]>--- fs/gfs2/incore.h | 1 - fs/gfs2/rgrp.c | 5 +++-- fs/gfs2/trace_gfs2.h | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-)fs/gfs2/incore.h +0
-1@@ -295,7 +295,6 @@ struct gfs2_blkreserv {struct rb_node rs_node;/* link to other block reservations */ struct gfs2_rbm rs_rbm;/* Start of reservation */ u32 rs_free;/* how many blocks are still free */ -u64 rs_inum;/* Inode number for reservation */ };/* fs/gfs2/rgrp.c +3
-2@@ -607,8 +607,10 @@ int gfs2_rsqa_alloc(struct gfs2_inode *ip)static void dump_rs (struct seq_file *seq,const struct gfs2_blkreserv *rs) { + struct gfs2_inode *ip = container_of(rs, struct gfs2_inode, i_res); +gfs2_print_dbg (seq," B: n:%llu s:%llu b:%u f:%u\n" , - (unsigned long long )rs->rs_inum, + (unsigned long long )ip->i_no_addr, (unsigned long long )gfs2_rbm_to_block (&rs->rs_rbm), rs->rs_rbm.offset, rs->rs_free); }@@ -1528,7 +1530,6 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,if (ret ==0 ) { rs->rs_rbm = rbm; rs->rs_free = extlen; - rs->rs_inum = ip->i_no_addr;rs_insert (ip); }else {if (goal == rgd->rd_last_alloc + rgd->rd_data0)fs/gfs2/trace_gfs2.h +0
-0
fs/gfs2/trace_gfs2.h TRACE_EVENT(gfs2_rs, · line 613
Quoted 9 lines
fs/gfs2/trace_gfs2.h +2
-1@@ -606,7 +606,8 @@ TRACE_EVENT(gfs2_rs, __entry->rd_addr = rs->rs_rbm.rgd->rd_addr; __entry->rd_free_clone = rs->rs_rbm.rgd->rd_free_clone; __entry->rd_reserved = rs->rs_rbm.rgd->rd_reserved; - __entry->inum = rs->rs_inum; + __entry->inum = container_of(rs, struct gfs2_inode, + i_res)->i_no_addr; __entry->start =gfs2_rbm_to_block (&rs->rs_rbm); __entry->free = rs->rs_free; __entry->func = func;
Thanks,
Andreas