Commit f9e2d82e authored by Mark Fasheh's avatar Mark Fasheh

ocfs2: Encode i_generation in the meta data lvb

When i_generation is removed from the lockname, this will help us determine
whether a meta data lvb has information that is in sync with the local
struct inode.
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 4d3b83f7
...@@ -1427,6 +1427,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode) ...@@ -1427,6 +1427,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
lvb->lvb_imtime_packed = lvb->lvb_imtime_packed =
cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime)); cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime));
lvb->lvb_iattr = cpu_to_be32(oi->ip_attr); lvb->lvb_iattr = cpu_to_be32(oi->ip_attr);
lvb->lvb_igeneration = cpu_to_be32(inode->i_generation);
mlog_meta_lvb(0, lockres); mlog_meta_lvb(0, lockres);
...@@ -1482,11 +1483,13 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode) ...@@ -1482,11 +1483,13 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
mlog_exit_void(); mlog_exit_void();
} }
static inline int ocfs2_meta_lvb_is_trustable(struct ocfs2_lock_res *lockres) static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode,
struct ocfs2_lock_res *lockres)
{ {
struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb;
if (lvb->lvb_version == OCFS2_LVB_VERSION) if (lvb->lvb_version == OCFS2_LVB_VERSION
&& be32_to_cpu(lvb->lvb_igeneration) == inode->i_generation)
return 1; return 1;
return 0; return 0;
} }
...@@ -1583,7 +1586,7 @@ static int ocfs2_meta_lock_update(struct inode *inode, ...@@ -1583,7 +1586,7 @@ static int ocfs2_meta_lock_update(struct inode *inode,
* map (directories, bitmap files, etc) */ * map (directories, bitmap files, etc) */
ocfs2_extent_map_trunc(inode, 0); ocfs2_extent_map_trunc(inode, 0);
if (ocfs2_meta_lvb_is_trustable(lockres)) { if (ocfs2_meta_lvb_is_trustable(inode, lockres)) {
mlog(0, "Trusting LVB on inode %llu\n", mlog(0, "Trusting LVB on inode %llu\n",
(unsigned long long)oi->ip_blkno); (unsigned long long)oi->ip_blkno);
ocfs2_refresh_inode_from_lvb(inode); ocfs2_refresh_inode_from_lvb(inode);
...@@ -3166,8 +3169,9 @@ void ocfs2_dump_meta_lvb_info(u64 level, ...@@ -3166,8 +3169,9 @@ void ocfs2_dump_meta_lvb_info(u64 level,
mlog(level, "LVB information for %s (called from %s:%u):\n", mlog(level, "LVB information for %s (called from %s:%u):\n",
lockres->l_name, function, line); lockres->l_name, function, line);
mlog(level, "version: %u, clusters: %u\n", mlog(level, "version: %u, clusters: %u, generation: 0x%x\n",
lvb->lvb_version, be32_to_cpu(lvb->lvb_iclusters)); lvb->lvb_version, be32_to_cpu(lvb->lvb_iclusters),
be32_to_cpu(lvb->lvb_igeneration));
mlog(level, "size: %llu, uid %u, gid %u, mode 0x%x\n", mlog(level, "size: %llu, uid %u, gid %u, mode 0x%x\n",
(unsigned long long)be64_to_cpu(lvb->lvb_isize), (unsigned long long)be64_to_cpu(lvb->lvb_isize),
be32_to_cpu(lvb->lvb_iuid), be32_to_cpu(lvb->lvb_igid), be32_to_cpu(lvb->lvb_iuid), be32_to_cpu(lvb->lvb_igid),
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "dcache.h" #include "dcache.h"
#define OCFS2_LVB_VERSION 3 #define OCFS2_LVB_VERSION 4
struct ocfs2_meta_lvb { struct ocfs2_meta_lvb {
__be16 lvb_reserved0; __be16 lvb_reserved0;
...@@ -45,7 +45,8 @@ struct ocfs2_meta_lvb { ...@@ -45,7 +45,8 @@ struct ocfs2_meta_lvb {
__be16 lvb_imode; __be16 lvb_imode;
__be16 lvb_inlink; __be16 lvb_inlink;
__be32 lvb_iattr; __be32 lvb_iattr;
__be32 lvb_reserved[2]; __be32 lvb_igeneration;
__be32 lvb_reserved2;
}; };
/* ocfs2_meta_lock_full() and ocfs2_data_lock_full() 'arg_flags' flags */ /* ocfs2_meta_lock_full() and ocfs2_data_lock_full() 'arg_flags' flags */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment