[Cluster-devel] [bug report] [GFS2] The core of GFS2

Steven Whitehouse swhiteho at redhat.com
Wed Jul 11 12:35:20 UTC 2018


Hi,


On 11/07/18 13:18, Dan Carpenter wrote:
> Hello David Teigland,
>
> The patch b3b94faa5fe5: "[GFS2] The core of GFS2" from Jan 16, 2006,
> leads to the following static checker warning:
>
> 	fs/gfs2/dir.c:1104 dir_split_leaf()
> 	warn: 'new' can also be NULL
>
> fs/gfs2/dir.c
>    1083          /*  Copy the entries  */
>    1084          dent = (struct gfs2_dirent *)(obh->b_data + sizeof(struct gfs2_leaf));
>    1085
>    1086          do {
>    1087                  next = dent;
>    1088                  if (dirent_next(dip, obh, &next))
>    1089                          next = NULL;
>    1090
>    1091                  if (!gfs2_dirent_sentinel(dent) &&
>    1092                      be32_to_cpu(dent->de_hash) < divider) {
>    1093                          struct qstr str;
>    1094                          void *ptr = ((char *)dent - obh->b_data) + nbh->b_data;
>    1095                          str.name = (char*)(dent+1);
>    1096                          str.len = be16_to_cpu(dent->de_name_len);
>    1097                          str.hash = be32_to_cpu(dent->de_hash);
>    1098                          new = gfs2_dirent_split_alloc(inode, nbh, &str, ptr);
>                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This returns both NULL and error pointers.  There is no documentation
> so I have no idea what the the returns mean.
That can only happen in case the gfs2_dirent_scan does not find any free 
space. Since the leaf block has been split immediately before we run 
gfs2_dirent_scan, it can only happen if something has come along and 
stomped on the newly split leaf block, which should be impossible, so it 
looks like a false positive to me,

Steve.

>
>    1099                          if (IS_ERR(new)) {
>    1100                                  error = PTR_ERR(new);
>    1101                                  break;
>    1102                          }
>    1103
>    1104                          new->de_inum = dent->de_inum; /* No endian worries */
>    1105                          new->de_type = dent->de_type; /* No endian worries */
>    1106                          be16_add_cpu(&nleaf->lf_entries, 1);
>    1107
>    1108                          dirent_del(dip, obh, prev, dent);
>    1109
>    1110                          if (!oleaf->lf_entries)
>    1111                                  gfs2_consist_inode(dip);
>    1112                          be16_add_cpu(&oleaf->lf_entries, -1);
>    1113
>    1114                          if (!prev)
>    1115                                  prev = dent;
>    1116
>    1117                          moved = 1;
>    1118                  } else {
>    1119                          prev = dent;
>    1120                  }
>    1121                  dent = next;
>    1122          } while (dent);
>    1123
>
> regards,
> dan carpenter
>




More information about the Cluster-devel mailing list