From nobody Thu Oct 17 19:58:00 2024 X-Original-To: freebsd-fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XTzCs1mBGz5ZQXW for ; Thu, 17 Oct 2024 19:58:17 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XTzCr6Ld2z4hKb for ; Thu, 17 Oct 2024 19:58:16 +0000 (UTC) (envelope-from asomers@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37d5aedd177so1076701f8f.1 for ; Thu, 17 Oct 2024 12:58:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729195095; x=1729799895; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k1sJF11Ujz16akELqq3hdauVGEzYuKrlSYIPwgKLiZg=; b=q8rOJQpzPQ5uQFWNrv5OD54XVSbrFCa+qpFJv8Q/3uzG1NW8dGgAhSz4EcVWhgR+d6 nt6wECJO9ZzONNyL3vZ6wxxumnbqkHsL9E1ln6oDAu9Z933UGWOpd9sZlIlHiupItdlO IO5GB9BQ9f7HghVmf5be3ilDKD99wXBPU0IrbiIjS4bxtRkBzhZw+FE2hQbRFDv5JXH0 5+zKG1M2vLusUOyPZYUeHcY/c7wLkb5a+M9lA7l/MI7VEnx37ULz4hTJGJPobpFOqLOM BM45wZ1lSGlIj967hKwlr5eoWgrzYPXwJtm9kYmoeBqtNWKso4TgLRIrtd+js2cnzjY9 HASw== X-Forwarded-Encrypted: i=1; AJvYcCVMhAz8SkGC+E+aRRTKI22hzLnWS/dm69sY/rzfnzfTb0kPf24eOdB00+wphBwJvk7DC6RwXws6ZbNK@freebsd.org X-Gm-Message-State: AOJu0Yxs+aOhsLXM1vhtEJs+vB9NvrBJnH9lFn7QURfPHBWjnpCz6Ft8 8KV8EBszkEhFSCN1lcv4TYjmslwvLY0nLVMex+HIXz14dNM2VRXIACphJgdJYQ5Ae7b1c1dAywE GgdPXuRk46Wg36os9pHB3iwbpeQK81A== X-Google-Smtp-Source: AGHT+IHgJLdfsEf946C4wsakkNOoRDiID3vdju0mqJ5MnLWQCLTHcr9/IDq0JV/36RiPKvpssOWLpfYVLtMn0FYynbc= X-Received: by 2002:a5d:56c8:0:b0:37d:49cc:cadc with SMTP id ffacd0b85a97d-37ea21c81cbmr61609f8f.32.1729195093180; Thu, 17 Oct 2024 12:58:13 -0700 (PDT) List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@FreeBSD.org MIME-Version: 1.0 References: In-Reply-To: From: Alan Somers Date: Thu, 17 Oct 2024 13:58:00 -0600 Message-ID: Subject: Re: Should VOP_RENAME fail if tdvp has an IMMUTABLE flag set? To: Konstantin Belousov Cc: mscotty@protonmail.ch, freebsd-fs Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] X-Rspamd-Queue-Id: 4XTzCr6Ld2z4hKb X-Spamd-Bar: ---- On Thu, Oct 17, 2024 at 1:35=E2=80=AFPM Konstantin Belousov wrote: > > On Thu, Oct 17, 2024 at 10:58:02AM -0600, Alan Somers wrote: > > On Wed, Oct 16, 2024 at 4:36=E2=80=AFPM Konstantin Belousov wrote: > > > > > > On Wed, Oct 16, 2024 at 04:11:28PM -0600, Alan Somers wrote: > > > > ufs_rename and ext2_rename will both fail with EPERM if the > > > > destination directory has an APPEND file flag set. So will > > > > tmpfs_rename. However, tmpfs_rename will also fail if the destinat= ion > > > > directory has an IMMUTABLE flag set. That's inconsistent. It seem= s > > > > to me that tmpfs's behavior is more reasonable. Does anybody know = why > > > > ufs and ext2 have always allowed rename even if the destination > > > > directory is IMMUTABLE? For that matter, does anybody know the > > > > rationale for preventing it if the destination is APPEND? > > > > Intuitively, I would think that an APPEND-only directory would allo= w > > > > new entries. And I don't see any checks for APPEND in ufs_mkdir, > > > > ufs_link, or ufs_create. > > > > > > For UFS, IMMUTABLE is checked on lookup. Search for 'RENAME' in ufs_= lookup.c > > > and following call to VOP_ACCESSX(). > > > > That makes sense. So an IMMUTABLE check in ufs_rename wouldn't be > > wrong, but it would be redundant. > > > > > > > > APPEND for UFS directories is a strange idea, for instance, does the = directory > > > compaction breaks append-only? > > > > I agree with olce@ on this one. Directory compaction sounds to me > > like an implementation detail. > But does the re-ordering of the directory entries counts against > append-only? Adding a new entry could occur in the middle of existing > entries, if there is an unused block. This would at least change cookies > and the order of returned dirents. That doesn't sound like a problem to me. No program should be relying on the order of entries returned by readdir, as long as they're consistent. And telldir/seekdir cookies make no promises about how they handle new dirents written after the cookie was created. > > Another question, if the target dirent already exists, and rename would > rewrite tvp inode number, is this fine for append-only? That does not sound fine to me, in append-only mode, because it's changing existing directory contents. > > > > > BTW, the motivation for this discussion is that mscotty (CC'd) is > > currently working on implementing file flags within fusefs. We're > > trying to decide exactly how to enforce them, following UFS's lead > > where possible. > > > > -Alan