From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ivanoab6.miniserver.com ([5.153.251.140] helo=www.kot-begemot.co.uk) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLECT-0007sG-57 for linux-um@lists.infradead.org; Fri, 09 Nov 2018 21:20:21 +0000 Subject: Re: [PATCH] Add DISCARD support to UML udb driver References: <20181109091937.25470-1-anton.ivanov@cambridgegreys.com> From: Anton Ivanov Message-ID: <79343bcf-8cf7-27e8-1d53-ee404f6431bd@cambridgegreys.com> Date: Fri, 9 Nov 2018 21:20:03 +0000 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: Richard Weinberger Cc: Jens Axboe , linux-um@lists.infradead.org, Christoph Hellwig On 09/11/2018 21:04, Richard Weinberger wrote: > On Fri, Nov 9, 2018 at 10:20 AM wrote: >> From: Anton Ivanov >> >> 1. Remove UBD specific opcode definitions and reuse the block-mq >> ones >> 2. Add DISCARD and ZERO fill support (tested with ext4). >> 3. Further cleanup on the request forming, request checking and >> handling of unexpected command codes. > As Jens already asked, please one patch per logical change. > Also make sure to use a proper subject line. > Either prefix with "um: ..." or "ubd: ...". > If prefer "um", but if it really affects only the ubd driver, "ubd:" > is fine too. Ack. I should have revised series on Monday. > >> +int os_falloc_punch(int fd, unsigned long long offset, int len) >> +{ >> + int n = fallocate(fd, FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE, offset, len); >> + >> + if (n < 0) >> + return -errno; >> + return n; >> +} > What shall happen if the host filesystem does not support these > fallocate() operations? > I guess we need to probe for them first and decide whether to > accept/offer the discard command > at run time. If it the filesystem is using periodic (not realtime) fstrim, It will return IO error on those and fstrim will fail. Normal file ops - write, read, fsync should continue as this should not force a remount. I could not test with realtime fstrim ans btrfs was having some issues in 4.20-rc1. It was hitting spinlock recursions and irq on/off where they should not be BUG()s. Non-destructive probing is a bit difficult. IMHO, we should leave this to the user and add flags the way nbd and loop have done it. We can also add a config option to set a default on or off at compile time (same as for sync io on ubd). Most major filesystems support the relevant flags since 3.x. I am not aware at what point did the libc function appear. A. > -- Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um