Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-20648

lfs changelog --mask is silently ignored for a user registered without a mask

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None
    • 3
    • 9223372036854775807

      lfs changelog --user NAME --mask creat returns every record type, not just
      CREAT, when NAME was registered without a mask. No error is reported. The
      request is a wrong answer rather than a failure, which is what makes it worth
      filing.

      A zero cf_mask means two different things, and the client composes them as
      if it meant one.

      Meaning one, on the server: "this user registered no mask of their own".
      mdd_chlg_usermask() returns cur_mask for a CHANGELOG_USER_REC2 and
      0 for the older record (lustre/mdd/mdd_device.c:233), and the lookup puts
      that in the reply (lustre/mdd/mdd_changelog.c:53).

      Meaning two, on the client: "do not filter". A zero
      crs_user_mask disables the test altogether
      (lustre/mdc/mdc_changelog.c:222-224):

              /* Check if this record type matches the user's mask */
              if (crs->crs_user_mask &&
                  !(crs->crs_user_mask & BIT(rec->cr.cr_type)))
                      RETURN(0);
      

      The two meanings meet in chlg_ioctl()
      (lustre/mdc/mdc_changelog.c:811-814), where in is the mask the caller
      asked for and out is the mask the user registered:

              if (in.cf_mask == 0)
                      crs->crs_user_mask = out.cf_mask;
              else
                      crs->crs_user_mask = in.cf_mask & out.cf_mask;
      

      So when the caller passes a mask and the user has none, the result is
      in.cf_mask & 0, which is 0, which the record test then reads as *do not
      filter*. The caller's mask is dropped and everything comes back.

      Which users have no mask

      Registration writes a rec2 when either a mask or a name was given
      (lustre/mdd/mdd_device.c:1789), but cur_mask is only assigned inside
      if (mask) (lustre/mdd/mdd_device.c:1817-1826). So a registration with a
      name and no mask produces a rec2 whose cur_mask is 0, and that user
      hits this today:

              lctl --device testfs-MDT0000 changelog register --user foo
              touch /mnt/testfs/a ; mkdir /mnt/testfs/d
              lfs changelog --user foo --mask creat testfs-MDT0000
                -> the MKDIR record is listed too
      

      A user registered with neither a mask nor a name gets the older record type,
      whose mask is 0 by definition, so every such user is affected as well. Those
      users cannot be looked up at all until LU-20647 is fixed, which is the only
      reason this is not visible for them yet.

      The fix

      Either give "no per-user mask" a value that is not zero, or stop treating the
      two zeros as the same thing when composing. The smaller change is a third arm:

              if (in.cf_mask == 0)
                      crs->crs_user_mask = out.cf_mask;
              else if (out.cf_mask == 0)
                      crs->crs_user_mask = in.cf_mask;
              else
                      crs->crs_user_mask = in.cf_mask & out.cf_mask;
      

      A user with no registered mask is not restricted to nothing; they are
      unrestricted, so intersecting with them should leave the caller's mask alone.

      How it was found

      Reading the reply path while fixing LU-20647, which makes a plainly registered
      user reachable by lookup for the first time and so would have exposed this to
      every such user.

            hnishida Hiroshi Nishida
            hnishida Hiroshi Nishida
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: